Zelda Classic Coverage Report


Directory: src/
File: src/zc/hero.cpp
Date: 2023-01-21 22:09:17
Exec Total Coverage
Lines: 11138 17018 65.4%
Functions: 238 317 75.1%
Branches: 9394 19728 47.6%

Line Branch Exec Source
1 //--------------------------------------------------------
2 //--------------------------------------------------------
3 //--------------------------------------------------------
4 // Zelda Classic
5 // by Jeremy Craner, 1999-2000
6 //
7 // hero.cpp
8 //
9 // Hero's class: HeroClass
10 // Handles a lot of game play stuff as well as Hero's
11 // movement, attacking, etc.
12 //
13 //--------------------------------------------------------
14
15 #ifndef __GTHREAD_HIDE_WIN32API
16 #define __GTHREAD_HIDE_WIN32API 1
17
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 #endif //prevent indirectly including windows.h
18
19 #include "precompiled.h" //always first
20
21 #include <string.h>
22 #include <set>
23 #include <stdio.h>
24
25 #include "hero.h"
26 #include "guys.h"
27 #include "subscr.h"
28 #include "zc_subscr.h"
29 #include "decorations.h"
30 #include "gamedata.h"
31 #include "zc_custom.h"
32 #include "title.h"
33 #include "ffscript.h"
34 #include "drawing.h"
35 #include "combos.h"
36 #include "base/zc_math.h"
37 #include "user_object.h"
38 #include "slopes.h"
39 extern FFScript FFCore;
40 extern word combo_doscript[176];
41 extern byte itemscriptInitialised[256];
42 extern HeroClass Hero;
43 extern ZModule zcm;
44 extern zcmodule moduledata;
45 extern refInfo playerScriptData;
46 #include "zscriptversion.h"
47 #include "particles.h"
48 #include <fmt/format.h>
49
50 extern refInfo itemScriptData[256];
51 extern refInfo itemCollectScriptData[256];
52 extern int32_t item_stack[256][MAX_SCRIPT_REGISTERS];
53 extern int32_t item_collect_stack[256][MAX_SCRIPT_REGISTERS];
54 extern refInfo *ri; //= NULL;
55 extern int32_t(*stack)[MAX_SCRIPT_REGISTERS];
56 extern byte dmapscriptInitialised;
57 extern word item_doscript[256];
58 extern word item_collect_doscript[256];
59 extern portal* mirror_portal;
60 using std::set;
61
62 extern int32_t skipcont;
63
64 extern int32_t draw_screen_clip_rect_x1;
65 extern int32_t draw_screen_clip_rect_x2;
66 extern int32_t draw_screen_clip_rect_y1;
67 extern int32_t draw_screen_clip_rect_y2;
68 extern word global_wait;
69 extern bool player_waitdraw;
70 extern bool dmap_waitdraw;
71 extern bool passive_subscreen_waitdraw;
72 extern bool active_subscreen_waitdraw;
73
74 int32_t hero_count = -1;
75 int32_t hero_animation_speed = 1; //lower is faster animation
76 int32_t z3step = 2;
77 23 static zfix hero_newstep(1.5);
78 23 static zfix hero_newstep_diag(1.5);
79 bool did_scripta=false;
80 bool did_scriptb=false;
81 bool did_scriptl=false;
82 byte lshift = 0;
83 int32_t dowpn = -1;
84 int32_t directItem = -1; //Is set if Hero is currently using an item directly
85 int32_t directItemA = -1;
86 int32_t directItemB = -1;
87 int32_t directItemX = -1;
88 int32_t directItemY = -1;
89 int32_t directWpn = -1;
90 int32_t whistleitem=-1;
91 extern word g_doscript;
92 extern word player_doscript;
93 extern word dmap_doscript;
94 extern word passive_subscreen_doscript;
95 extern byte epilepsyFlashReduction;
96 extern int32_t script_hero_cset;
97
98 void playLevelMusic();
99
100 extern particle_list particles;
101
102 byte lsteps[8] = { 1, 1, 2, 1, 1, 2, 1, 1 };
103
104 #define CANFORCEFACEUP (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0 && dir!=up && (action==walking || action==none))
105 #define NO_GRIDLOCK (get_bit(quest_rules, qr_DISABLE_4WAY_GRIDLOCK))
106 #define SWITCHBLOCK_STATE (switchblock_z<0?switchblock_z:(switchblock_z+z+fakez < 0 ? zslongToFix(2147483647) : switchblock_z+z+fakez))
107 #define FIXED_Z3_ANIMATION ((zinit.heroAnimationStyle==las_zelda3||zinit.heroAnimationStyle==las_zelda3slow)&&!get_bit(quest_rules,qr_BROKEN_Z3_ANIMATION))
108
109 15 bool item_error()
110 {
111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(QMisc.miscsfx[sfxERROR])
112 sfx(QMisc.miscsfx[sfxERROR]);
113 15 return false;
114 }
115 8480472 static inline bool on_sideview_slope(int32_t x, int32_t y, int32_t oldx, int32_t oldy)
116 {
117
2/2
✓ Branch 0 taken 12627 times.
✓ Branch 1 taken 8467845 times.
8480472 if(check_new_slope(x, y+1, 16, 16, oldx, oldy) < 0) return true;
118 8467845 return false;
119 8480472 }
120
121 2832347 static inline bool platform_fallthrough(bool doslopecheck = true)
122 {
123
5/6
✓ Branch 0 taken 2832347 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2826309 times.
✓ Branch 3 taken 6038 times.
✓ Branch 4 taken 2821792 times.
✓ Branch 5 taken 4517 times.
7710261 return (doslopecheck && !on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0))
124
2/2
✓ Branch 0 taken 394960 times.
✓ Branch 1 taken 388922 times.
2832347 || (getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0) && get_bit(quest_rules,qr_DOWN_FALL_THROUGH_SIDEVIEW_PLATFORMS))
125
6/6
✓ Branch 0 taken 2047016 times.
✓ Branch 1 taken 2441976 times.
✓ Branch 2 taken 5952 times.
✓ Branch 3 taken 2824946 times.
✓ Branch 4 taken 4632 times.
✓ Branch 5 taken 1320 times.
783882 || (Hero.jumping < 0 && getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0) && get_bit(quest_rules,qr_DOWNJUMP_FALL_THROUGH_SIDEVIEW_PLATFORMS));
126 }
127
128 static inline bool on_sideview_solid(int32_t x, int32_t y, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
129 {
130 if(slopesmisc != 1 && check_slope(x, y+1, 16, 16, (slopesmisc == 3)) < 0) return true;
131 if(slopesmisc == 2) return false;
132 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
133 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
134 if (platform_fallthrough() && !ignoreFallthrough) return false;
135 if(slopesmisc != 1 && check_slope(x, y+1, 16, 16) < 0) return true;
136 if (y%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
137 return true;
138 return false;
139 }
140
141 3760101 static inline bool on_sideview_solid_oldpos(int32_t x, int32_t y, int32_t oldx, int32_t oldy, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
142 {
143
4/4
✓ Branch 0 taken 332585 times.
✓ Branch 1 taken 3427516 times.
✓ Branch 2 taken 301655 times.
✓ Branch 3 taken 30930 times.
3760101 if(slopesmisc != 1 && check_new_slope(x, y+1, 16, 16, oldx, oldy, (slopesmisc == 3)) < 0) return true;
144
2/2
✓ Branch 0 taken 14536 times.
✓ Branch 1 taken 3714635 times.
3729171 if(slopesmisc == 2) return false;
145
4/4
✓ Branch 0 taken 2905116 times.
✓ Branch 1 taken 809519 times.
✓ Branch 2 taken 72301 times.
✓ Branch 3 taken 2832815 times.
3714635 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
146
6/6
✓ Branch 0 taken 11963 times.
✓ Branch 1 taken 2820852 times.
✓ Branch 2 taken 715 times.
✓ Branch 3 taken 11248 times.
✓ Branch 4 taken 247 times.
✓ Branch 5 taken 468 times.
2832815 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
147
4/4
✓ Branch 0 taken 1488 times.
✓ Branch 1 taken 2830859 times.
✓ Branch 2 taken 210 times.
✓ Branch 3 taken 1278 times.
2832347 if (platform_fallthrough() && !ignoreFallthrough) return false;
148
4/4
✓ Branch 0 taken 115284 times.
✓ Branch 1 taken 2715785 times.
✓ Branch 2 taken 114054 times.
✓ Branch 3 taken 1230 times.
2831069 if (slopesmisc != 1 && check_new_slope(x, y + 1, 16, 16, oldx, oldy) < 0) return true;
149
6/6
✓ Branch 0 taken 770286 times.
✓ Branch 1 taken 2059553 times.
✓ Branch 2 taken 761532 times.
✓ Branch 3 taken 8754 times.
✓ Branch 4 taken 13 times.
✓ Branch 5 taken 761519 times.
2829839 if (y%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
150 8767 return true;
151 2821072 return false;
152 3760101 }
153
154
155 9867324 bool usingActiveShield(int32_t itmid)
156 {
157
2/2
✓ Branch 0 taken 8205229 times.
✓ Branch 1 taken 1662095 times.
9867324 switch(Hero.action) //filter allowed actions
158 {
159 case none: case walking: case rafting:
160 case gothit: case swimhit:
161 8205229 break;
162 1662095 default: return false;
163 }
164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8205229 times.
8205229 if(itmid < 0)
165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8205229 times.
8205229 itmid = (Hero.active_shield_id < 0
166 8205229 ? current_item_id(itype_shield,true,true) : Hero.active_shield_id);
167
2/2
✓ Branch 0 taken 7508759 times.
✓ Branch 1 taken 696470 times.
8205229 if(itmid < 0) return false;
168
1/2
✓ Branch 0 taken 7508759 times.
✗ Branch 1 not taken.
7508759 if(!checkitem_jinx(itmid)) return false;
169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7508759 times.
7508759 if(!(itemsbuf[itmid].flags & ITEM_FLAG9)) return false;
170 if(!isItmPressed(itmid)) return false;
171 return (checkbunny(itmid) && checkmagiccost(itmid));
172 9867324 }
173 6007057 int32_t getCurrentShield(bool requireActive)
174 {
175
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6007057 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6007057 if(Hero.active_shield_id > -1 && usingActiveShield(Hero.active_shield_id))
176 return Hero.active_shield_id;
177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6007057 times.
6007057 if(!requireActive) return current_item_id(itype_shield);
178 return -1;
179 6007057 }
180 81905 int32_t getCurrentActiveShield()
181 {
182 81905 int32_t id = Hero.active_shield_id;
183
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 81905 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
81905 if(id > -1 && usingActiveShield(id))
184 return id;
185 81905 return -1;
186 81905 }
187 3394924 int32_t refreshActiveShield()
188 {
189 3394924 int32_t id = -1;
190
2/2
✓ Branch 0 taken 3277450 times.
✓ Branch 1 taken 117474 times.
3394924 if(DrunkcBbtn())
191 {
192 117474 itemdata const& dat = itemsbuf[Bwpn&0xFFF];
193
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 117474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
117474 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
194 {
195 id = Bwpn&0xFFF;
196 }
197 117474 }
198
3/4
✓ Branch 0 taken 3394924 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2978867 times.
✓ Branch 3 taken 416057 times.
3394924 if(id < 0 && DrunkcAbtn())
199 {
200 416057 itemdata const& dat = itemsbuf[Awpn&0xFFF];
201
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 416057 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
416057 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
202 {
203 id = Awpn&0xFFF;
204 }
205 416057 }
206
3/4
✓ Branch 0 taken 3394924 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3394903 times.
✓ Branch 3 taken 21 times.
3394924 if(id < 0 && DrunkcEx1btn())
207 {
208 21 itemdata const& dat = itemsbuf[Xwpn&0xFFF];
209
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
21 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
210 {
211 id = Xwpn&0xFFF;
212 }
213 21 }
214
3/4
✓ Branch 0 taken 3394924 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3393811 times.
✓ Branch 3 taken 1113 times.
3394924 if(id < 0 && DrunkcEx2btn())
215 {
216 1113 itemdata const& dat = itemsbuf[Ywpn&0xFFF];
217
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1113 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1113 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
218 {
219 id = Ywpn&0xFFF;
220 }
221 1113 }
222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3394924 times.
3394924 if(!usingActiveShield(id))
223 3394924 return -1;
224 return id;
225 3394924 }
226 static bool is_immobile()
227 {
228 if(!get_bit(quest_rules, qr_NEW_HERO_MOVEMENT))
229 return false;
230 zfix rate(Hero.steprate);
231 int32_t shieldid = getCurrentActiveShield();
232 if(shieldid > -1)
233 {
234 itemdata const& shield = itemsbuf[shieldid];
235 if(shield.flags & ITEM_FLAG10) //Change Speed flag
236 {
237 zfix perc = shield.misc7;
238 perc /= 100;
239 if(perc < 0)
240 perc = (perc*-1)+1;
241 rate = (rate * perc) + shield.misc8;
242 }
243 }
244 return rate != 0;
245 }
246
247 3579115 bool HeroClass::isStanding(bool forJump)
248 {
249
11/14
✓ Branch 0 taken 3575678 times.
✓ Branch 1 taken 3437 times.
✓ Branch 2 taken 3575678 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 40580 times.
✓ Branch 5 taken 3535098 times.
✓ Branch 6 taken 17543 times.
✓ Branch 7 taken 23037 times.
✓ Branch 8 taken 17543 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 17543 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 428 times.
✓ Branch 13 taken 17115 times.
3579115 bool st = (z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !ladderx && !laddery && !getOnSideviewLadder()) && hoverclk==0);
250
2/2
✓ Branch 0 taken 3558563 times.
✓ Branch 1 taken 20552 times.
3579115 if(!st) return false;
251 3558563 int32_t val = check_pitslide();
252
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 3558339 times.
3558563 if(val == -2) return false;
253
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 3558328 times.
3558339 if(val == -1) return true;
254 11 return forJump;
255 3579115 }
256 15079 bool HeroClass::isLifting()
257 {
258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15079 times.
15079 if(lift_wpn) return true;
259 15079 return false;
260 15079 }
261
262 23860 void HeroClass::set_respawn_point(bool setwarp)
263 {
264
2/2
✓ Branch 0 taken 19385 times.
✓ Branch 1 taken 4475 times.
23860 if(setwarp)
265 {
266 4475 warpx = x;
267 4475 warpy = y;
268 4475 raftwarpx = x;
269 4475 raftwarpy = y;
270 4475 }
271
2/2
✓ Branch 0 taken 9316 times.
✓ Branch 1 taken 14544 times.
23860 if(!get_bit(quest_rules,qr_OLD_RESPAWN_POINTS))
272 {
273
2/2
✓ Branch 0 taken 14370 times.
✓ Branch 1 taken 174 times.
14544 switch(action)
274 {
275 case none: case walking:
276 14370 break;
277 default:
278 174 return; //Not a 'safe action'
279 }
280
3/6
✓ Branch 0 taken 14370 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14370 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 14370 times.
14370 if(z > 0 || fakez > 0 || hoverclk) return; //in air
281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14370 times.
14370 if(check_pitslide(true) != -1) return; //On a pit
282
283 { //Check water
284 14370 int32_t water = 0;
285 14370 int32_t types[4] = {0};
286 14370 int32_t x1 = x+4, x2 = x+11,
287 14370 y1 = y+9, y2 = y+15;
288
1/2
✓ Branch 0 taken 14370 times.
✗ Branch 1 not taken.
14370 if (get_bit(quest_rules, qr_SMARTER_WATER))
289 {
290
3/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 14349 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
14372 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
291
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 19 times.
21 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
292
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
293 2 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
294 14370 }
295 else
296 {
297 types[0] = COMBOTYPE(x1,y1);
298
299 if(MAPFFCOMBO(x1,y1))
300 types[0] = FFCOMBOTYPE(x1,y1);
301
302 types[1] = COMBOTYPE(x1,y2);
303
304 if(MAPFFCOMBO(x1,y2))
305 types[1] = FFCOMBOTYPE(x1,y2);
306
307 types[2] = COMBOTYPE(x2,y1);
308
309 if(MAPFFCOMBO(x2,y1))
310 types[2] = FFCOMBOTYPE(x2,y1);
311
312 types[3] = COMBOTYPE(x2,y2);
313
314 if(MAPFFCOMBO(x2,y2))
315 types[3] = FFCOMBOTYPE(x2,y2);
316
317 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
318 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
319 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
320
321 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
322 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
323 water = typec;
324 }
325
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 14368 times.
14370 if(water > 0)
326 {
327 2 return;
328 }
329 } //End check water
330
331 71840 int poses[4] = {
332 14368 COMBOPOS(x,y+(bigHitbox?0:8)),
333 14368 COMBOPOS(x,y+15),
334 14368 COMBOPOS(x+15,y+(bigHitbox?0:8)),
335 14368 COMBOPOS(x+15,y+15)
336 };
337
2/2
✓ Branch 0 taken 57472 times.
✓ Branch 1 taken 14368 times.
71840 for(auto pos : poses)
338 {
339
1/2
✓ Branch 0 taken 57472 times.
✗ Branch 1 not taken.
57472 if(HASFLAG_ANY(mfUNSAFEGROUND, pos)) //"Unsafe Ground" flag touching the player
340 return;
341 }
342 14368 }
343 23684 respawn_x = x;
344 23684 respawn_y = y;
345 23684 respawn_scr = currscr;
346 23684 respawn_dmap = currdmap;
347 23860 }
348
349 14 void HeroClass::go_respawn_point()
350 {
351 14 x = respawn_x;
352 14 y = respawn_y;
353 14 can_mirror_portal = false; //incase entry is on a portal!
354 14 warpx=x;
355 14 warpy=y;
356 14 raftwarpx = x;
357 14 raftwarpy = y;
358 14 trySideviewLadder(); //Cling to ladder automatically
359
360
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12 times.
14 if(get_bit(quest_rules, qr_OLD_RESPAWN_POINTS))
361 12 return; //No cross-screen return
362
363
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(currdmap != respawn_dmap || currscr != respawn_scr)
364 {
365 FFCore.warp_player(wtIWARP, respawn_dmap, respawn_scr,
366 -1, -1, 0, 0, warpFlagNOSTEPFORWARD|warpFlagDONTKILLMUSIC, -1);
367 }
368 14 }
369
370 5569 void HeroClass::trySideviewLadder()
371 {
372
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5569 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5569 if(canSideviewLadder() && !on_sideview_solid_oldpos(x,y,old_x,old_y))
373 setOnSideviewLadder(true);
374 5569 }
375
376 15828988 bool HeroClass::can_pitfall(bool ignore_hover)
377 {
378
26/30
✓ Branch 0 taken 15735206 times.
✓ Branch 1 taken 93782 times.
✓ Branch 2 taken 15683696 times.
✓ Branch 3 taken 51510 times.
✓ Branch 4 taken 15677158 times.
✓ Branch 5 taken 6538 times.
✓ Branch 6 taken 15677158 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 15677138 times.
✓ Branch 9 taken 20 times.
✓ Branch 10 taken 15677138 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 15677138 times.
✓ Branch 14 taken 15669719 times.
✓ Branch 15 taken 7419 times.
✓ Branch 16 taken 15668852 times.
✓ Branch 17 taken 867 times.
✓ Branch 18 taken 15668338 times.
✓ Branch 19 taken 514 times.
✓ Branch 20 taken 15588098 times.
✓ Branch 21 taken 80240 times.
✓ Branch 22 taken 15359131 times.
✓ Branch 23 taken 228967 times.
✓ Branch 24 taken 15358851 times.
✓ Branch 25 taken 280 times.
✓ Branch 26 taken 15358851 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 2240 times.
✓ Branch 29 taken 15356611 times.
15828988 return (!(isSideViewGravity()||action==rafting||z>0||fakez>0||fall<0||fakefall<0||(hoverclk && !ignore_hover)||inlikelike||inwallm||pull_hero||toogam||(ladderx||laddery)||getOnSideviewLadder()||drownclk||!(moveflags & FLAG_CAN_PITFALL)));
379 }
380
381 1962141 int32_t HeroClass::DrunkClock()
382 {
383 1962141 return drunkclk;
384 }
385 void HeroClass::setDrunkClock(int32_t newdrunkclk)
386 {
387 drunkclk=newdrunkclk;
388 }
389
390 int32_t HeroClass::StunClock()
391 {
392 return lstunclock;
393 }
394 void HeroClass::setStunClock(int32_t v)
395 {
396 lstunclock=v;
397 }
398
399 52525268 int32_t HeroClass::BunnyClock()
400 {
401 52525268 return lbunnyclock;
402 }
403 void HeroClass::setBunnyClock(int32_t v)
404 {
405 lbunnyclock=v;
406 }
407
408
9/18
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 23 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 23 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 23 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 23 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 23 times.
✗ Branch 17 not taken.
69 HeroClass::HeroClass() : sprite()
409 46 {
410 23 lift_wpn = nullptr;
411
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 init();
412 23 }
413
414 //2.6
415
416 //Stop the subscreen from falling. -Z
417
418 465 bool HeroClass::stopSubscreenFalling(){
419 465 return preventsubscreenfalling;
420 }
421
422 void HeroClass::stopSubscreenFalling(bool v){
423 preventsubscreenfalling = v;
424 }
425
426
427 //Set the button items by brute force
428
429 void HeroClass::setAButtonItem(int32_t itmslot){
430 game->awpn = itmslot;
431 }
432
433 void HeroClass::setBButtonItem(int32_t itmslot){
434 game->bwpn = itmslot;
435 }
436
437 3395231 void HeroClass::ClearhitHeroUIDs()
438 { //Why the flidd doesn't this work?! Clearing this to 0 in a way that doesn't demolish script access is impossible. -Z
439 //All I want, is to clear it at the end of a frame, or at the start of a frame, so that if it changes to non-0
440 //that a script can read it before Waitdraw(). --I want it to go stale at the end of a frame.
441 //I suppose I will need to do this inside the script engine, and not the game_loop() ? -Z
442 //THis started out as a simple clear to 0 of lastHitBy[n], but that did not work:
443 //I added the second element to this, so that I could store the frame on which the hit is recorded, and
444 //clear it on the next frame, but that had the SAME outcome.
445 //Where and how can I clear a value at the end of every frame, so that:
446 // 1. If set by internal mecanics, it has its value that you can read by script, before waitdraw--this part works at present.
447 // 2. FFCs can read it before Waitframe. --same.
448 // 3. After Waitframe(), it is wiped by the ZC Engine to 0. --I cannot get this to happen without breaking 1 and 2.
449
2/2
✓ Branch 0 taken 27161848 times.
✓ Branch 1 taken 3395231 times.
30557079 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED_PLAYER; q++ )
450 {
451 /*
452 if ( lastHitBy[q][1] == (frame-1) ) //Verify if this is needed at all now.
453 {
454 //Z_scripterrlog("frame is: %d\n", frame);
455 //Z_scripterrlog("Player->HitBy frame is: %d\n", lastHitBy[q][1]);
456 lastHitBy[q][0] = 0;
457 }
458 */
459 27161848 lastHitBy[q][0] = 0;
460 27161848 }
461 3395231 }
462
463 8434 void HeroClass::sethitHeroUID(int32_t type, int32_t screen_index)
464 {
465 8434 lastHitBy[type][0] = screen_index;
466 8434 }
467
468 2929 int32_t HeroClass::gethitHeroUID(int32_t type)
469 {
470 2929 return lastHitBy[type][0];
471 }
472
473 void HeroClass::set_defence(int32_t type, int32_t v)
474 {
475 defence[type] = v;
476 }
477
478 int32_t HeroClass::get_defence(int32_t type)
479 {
480 return defence[type];
481 }
482
483
484 //Set Hero;s hurt sfx
485 void HeroClass::setHurtSFX(int32_t sfx)
486 {
487 QMisc.miscsfx[sfxHURTPLAYER] = sfx;
488 }
489 4322 int32_t HeroClass::getHurtSFX()
490 {
491 4322 return QMisc.miscsfx[sfxHURTPLAYER];
492 }
493
494 bool HeroClass::getDiagMove()
495 {
496 return diagonalMovement;
497 }
498 void HeroClass::setDiagMove(bool newdiag)
499 {
500 diagonalMovement=newdiag;
501 }
502 9024 bool HeroClass::getBigHitbox()
503 {
504 9024 return bigHitbox;
505 }
506 179 void HeroClass::setBigHitbox(bool newbigHitbox)
507 {
508 179 bigHitbox=newbigHitbox;
509 179 syofs = bigHitbox?0:8;
510 179 sysz_ofs = bigHitbox?0:-8;
511 179 }
512 5424 int32_t HeroClass::getStepRate()
513 {
514 5424 return steprate;
515 }
516 void HeroClass::setStepRate(int32_t newrate)
517 {
518 steprate = newrate;
519 }
520 int32_t HeroClass::getSwimUpRate()
521 {
522 return game->get_sideswim_up();
523 }
524 void HeroClass::setSwimUpRate(int32_t newrate)
525 {
526 game->set_sideswim_up(newrate);
527 }
528 int32_t HeroClass::getSwimSideRate()
529 {
530 return game->get_sideswim_side();
531 }
532 void HeroClass::setSwimSideRate(int32_t newrate)
533 {
534 game->set_sideswim_side(newrate);
535 }
536 int32_t HeroClass::getSwimDownRate()
537 {
538 return game->get_sideswim_down();
539 }
540 void HeroClass::setSwimDownRate(int32_t newrate)
541 {
542 game->set_sideswim_down(newrate);
543 }
544
545
546 //void HeroClass::herostep() { lstep = lstep<(BSZ?27:11) ? lstep+1 : 0; }
547 2430269 void HeroClass::herostep()
548 {
549
2/2
✓ Branch 0 taken 2222928 times.
✓ Branch 1 taken 207341 times.
2430269 lstep = lstep<((zinit.heroAnimationStyle==las_bszelda)?27:11) ? lstep+1 : 0;
550 //need to run all global/hero/dmap scripts here?
551 2430269 }
552
553 25670 bool is_moving()
554 {
555
6/6
✓ Branch 0 taken 22246 times.
✓ Branch 1 taken 3424 times.
✓ Branch 2 taken 18121 times.
✓ Branch 3 taken 4125 times.
✓ Branch 4 taken 8185 times.
✓ Branch 5 taken 9936 times.
25670 return DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight();
556 }
557
558 // called by ALLOFF()
559 6502 void HeroClass::resetflags(bool all)
560 {
561 6502 refilling=REFILL_NONE;
562 6502 inwallm=false;
563 6502 inlikelike=blowcnt=whirlwind=specialcave=hclk=fairyclk=refill_why=didstuff=0;
564 6502 usecounts.clear();
565
566
4/4
✓ Branch 0 taken 6478 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 6393 times.
6502 if(swordclk>0 || all)
567 {
568 109 swordclk=0;
569 109 verifyAWpn();
570 109 }
571
4/4
✓ Branch 0 taken 6497 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 6412 times.
6502 if(itemclk>0 || all)
572 90 itemclk=0;
573
574
2/2
✓ Branch 0 taken 6417 times.
✓ Branch 1 taken 85 times.
6502 if(all)
575 {
576 85 NayrusLoveShieldClk=0;
577
578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if(nayruitem != -1)
579 {
580 stop_sfx(itemsbuf[nayruitem].usesound);
581 stop_sfx(itemsbuf[nayruitem].usesound+1);
582 }
583
584 85 nayruitem = -1;
585 85 hoverclk=jumping=0;
586 85 hoverflags = 0;
587 85 }
588 6502 damageovertimeclk = 0;
589 6502 newconveyorclk = 0;
590 6502 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
591
2/2
✓ Branch 0 taken 6502 times.
✓ Branch 1 taken 45514 times.
52016 for(auto q = 0; q < 7; ++q)
592 45514 hooked_undercombos[q] = -1;
593 6502 hopclk=0;
594 6502 hopdir=-1;
595 6502 attackclk=0;
596 6502 stomping=false;
597 6502 reset_swordcharge();
598 6502 diveclk=drownclk=drownCombo=0;
599 6502 action=none; FFCore.setHeroAction(none);
600 6502 conveyor_flags=0;
601 6502 magiccastclk=0;
602 6502 magicitem=-1;
603 6502 }
604
605 //Can use this for Hero->Stun. -Z
606 4652 void HeroClass::Freeze()
607 {
608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4652 times.
4652 if (action != inwind)
609 {
610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4652 times.
4652 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
611 4652 else {action=freeze; FFCore.setHeroAction(freeze);}
612 // also cancel Hero's attack
613 4652 attackclk = 0;
614 4652 }
615 4652 }
616 527 void HeroClass::unfreeze()
617 {
618
3/4
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 162 times.
✓ Branch 2 taken 365 times.
✗ Branch 3 not taken.
527 if(action==freeze && fairyclk<1) { action=none; FFCore.setHeroAction(none); }
619
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 527 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
527 if(action==sideswimfreeze && fairyclk<1) { action=sideswimming; FFCore.setHeroAction(sideswimming); }
620 527 }
621
622 11 void HeroClass::Drown(int32_t state)
623 {
624 // Hero should never drown if the ladder is out
625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(ladderx+laddery)
626 return;
627
628 11 drop_liftwpn();
629
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 switch(state)
630 {
631 case 1:
632 action=lavadrowning; FFCore.setHeroAction(lavadrowning);
633 attackclk=0;
634 attack=wNone;
635 attackid=-1;
636 reset_swordcharge();
637 drownclk=64;
638 z=fakez=fall=fakefall=0;
639 break;
640
641
642 default:
643 {
644
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM)){action=sidedrowning; FFCore.setHeroAction(sidedrowning);}
645 11 else {action=drowning; FFCore.setHeroAction(drowning);}
646 11 attackclk=0;
647 11 attack=wNone;
648 11 attackid=-1;
649 11 reset_swordcharge();
650 11 drownclk=64;
651 11 z=fakez=fall=fakefall=0;
652 11 break;
653 }
654 }
655
656 11 }
657
658 357 void HeroClass::finishedmsg()
659 {
660 //these are to cancel out any keys that Hero may
661 //be pressing so he doesn't attack at the end of
662 //a message if he was scrolling through it quickly.
663 357 rAbtn();
664 357 rBbtn();
665 357 unfreeze();
666
667
2/4
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 357 times.
714 if(action == landhold1 ||
668
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 action == landhold2 ||
669
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 action == waterhold1 ||
670
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 action == waterhold2 ||
671
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 action == sidewaterhold1 ||
672 357 action == sidewaterhold2)
673 {
674 holdclk = 1;
675 }
676 357 }
677 28 void HeroClass::setEaten(int32_t i)
678 {
679 28 inlikelike=i;
680 28 }
681 25 int32_t HeroClass::getEaten()
682 {
683 25 return inlikelike;
684 }
685 6924219 zfix HeroClass::getX()
686 {
687 6924219 return x;
688 }
689 6530121 zfix HeroClass::getY()
690 {
691 6530121 return y;
692 }
693 24477540 zfix HeroClass::getZ()
694 {
695 24477540 return z;
696 }
697 16957115 zfix HeroClass::getFakeZ()
698 {
699 16957115 return fakez;
700 }
701 140960 zfix HeroClass::getFall()
702 {
703 140960 return fall;
704 }
705 zfix HeroClass::getFakeFall()
706 {
707 return fakefall;
708 }
709 zfix HeroClass::getXOfs()
710 {
711 return xofs;
712 }
713 zfix HeroClass::getYOfs()
714 {
715 return yofs;
716 }
717 void HeroClass::setXOfs(int32_t newxofs)
718 {
719 xofs=newxofs;
720 }
721 void HeroClass::setYOfs(int32_t newyofs)
722 {
723 yofs=newyofs;
724 }
725 int32_t HeroClass::getHXOfs()
726 {
727 return hxofs;
728 }
729 int32_t HeroClass::getHYOfs()
730 {
731 return hyofs;
732 }
733 int32_t HeroClass::getHXSz()
734 {
735 return hxsz;
736 }
737 int32_t HeroClass::getHYSz()
738 {
739 return hysz;
740 }
741 19264 zfix HeroClass::getClimbCoverX()
742 {
743 19264 return climb_cover_x;
744 }
745 19264 zfix HeroClass::getClimbCoverY()
746 {
747 19264 return climb_cover_y;
748 }
749 int32_t HeroClass::getLadderX()
750 {
751 return ladderx;
752 }
753 int32_t HeroClass::getLadderY()
754 {
755 return laddery;
756 }
757
758 2446 void HeroClass::setX(int32_t new_x)
759 {
760 2446 zfix dx=new_x-x;
761 2446 justmoved = 2;
762
1/2
✓ Branch 0 taken 2446 times.
✗ Branch 1 not taken.
2446 if(Lwpns.idFirst(wHookshot)>-1)
763 {
764 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
765 hs_startx+=(int32_t)dx;
766 }
767
768
1/2
✓ Branch 0 taken 2446 times.
✗ Branch 1 not taken.
2446 if(Lwpns.idFirst(wHSHandle)>-1)
769 {
770 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
771 }
772
773
1/2
✓ Branch 0 taken 2446 times.
✗ Branch 1 not taken.
2446 if(chainlinks.Count()>0)
774 {
775 for(int32_t j=0; j<chainlinks.Count(); j++)
776 {
777 chainlinks.spr(j)->x+=dx;
778 }
779 }
780
781 2446 x=new_x;
782
783 // A kludge
784
4/4
✓ Branch 0 taken 2089 times.
✓ Branch 1 taken 357 times.
✓ Branch 2 taken 1464 times.
✓ Branch 3 taken 625 times.
2446 if(!diagonalMovement && dir<=down)
785 625 is_on_conveyor=true;
786 2446 }
787
788 2286 void HeroClass::setY(int32_t new_y)
789 {
790 2286 zfix dy=new_y-y;
791 2286 justmoved = 2;
792
1/2
✓ Branch 0 taken 2286 times.
✗ Branch 1 not taken.
2286 if(Lwpns.idFirst(wHookshot)>-1)
793 {
794 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
795 hs_starty+=(int32_t)dy;
796 }
797
798
1/2
✓ Branch 0 taken 2286 times.
✗ Branch 1 not taken.
2286 if(Lwpns.idFirst(wHSHandle)>-1)
799 {
800 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
801 }
802
803
1/2
✓ Branch 0 taken 2286 times.
✗ Branch 1 not taken.
2286 if(chainlinks.Count()>0)
804 {
805 for(int32_t j=0; j<chainlinks.Count(); j++)
806 {
807 chainlinks.spr(j)->y+=dy;
808 }
809 }
810
811 2286 y=new_y;
812
813 // A kludge
814
4/4
✓ Branch 0 taken 2089 times.
✓ Branch 1 taken 197 times.
✓ Branch 2 taken 625 times.
✓ Branch 3 taken 1464 times.
2286 if(!diagonalMovement && dir>=left)
815 1464 is_on_conveyor=true;
816 2286 }
817
818 2 void HeroClass::setZ(int32_t new_z)
819 {
820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(isSideViewHero())
821 return;
822
823
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(z==0 && new_z > 0)
824 {
825
1/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 switch(action)
826 {
827 case swimming:
828 {
829 diveclk=0;
830 action=walking; FFCore.setHeroAction(walking);
831 break;
832 }
833
834 case waterhold1:
835 {
836 action=landhold1; FFCore.setHeroAction(landhold1);
837 break;
838 }
839
840 case waterhold2:
841 {
842 action=landhold2; FFCore.setHeroAction(landhold2);
843 break;
844 }
845
846 default:
847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(charging) //!DIMITODO: Let Hero jump while charging sword
848 {
849 reset_swordcharge();
850 attackclk=0;
851 }
852
853 2 break;
854 }
855 2 }
856
857
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 z=(new_z>0 ? new_z : 0);
858 2 }
859
860 void HeroClass::setFakeZ(int32_t new_z)
861 {
862 if(isSideViewHero())
863 return;
864
865 if(fakez==0 && new_z > 0)
866 {
867 switch(action)
868 {
869 case swimming:
870 {
871 diveclk=0;
872 action=walking; FFCore.setHeroAction(walking);
873 break;
874 }
875
876 case waterhold1:
877 {
878 action=landhold1; FFCore.setHeroAction(landhold1);
879 break;
880 }
881
882 case waterhold2:
883 {
884 action=landhold2; FFCore.setHeroAction(landhold2);
885 break;
886 }
887
888 default:
889 if(charging) //!DIMITODO: Let Hero jump while charging sword
890 {
891 reset_swordcharge();
892 attackclk=0;
893 }
894
895 break;
896 }
897 }
898
899 fakez=(new_z>0 ? new_z : 0);
900 }
901
902 1211 void HeroClass::setXfix(zfix new_x)
903 {
904 //Z_scripterrlog("setxdbl: %f\n",new_x);
905 1211 zfix dx=new_x-x;
906 1211 justmoved = 2;
907
1/2
✓ Branch 0 taken 1211 times.
✗ Branch 1 not taken.
1211 if(Lwpns.idFirst(wHookshot)>-1)
908 {
909 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
910 hs_startx+=(int32_t)dx;
911 }
912
913
1/2
✓ Branch 0 taken 1211 times.
✗ Branch 1 not taken.
1211 if(Lwpns.idFirst(wHSHandle)>-1)
914 {
915 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
916 }
917
918
1/2
✓ Branch 0 taken 1211 times.
✗ Branch 1 not taken.
1211 if(chainlinks.Count()>0)
919 {
920 for(int32_t j=0; j<chainlinks.Count(); j++)
921 {
922 chainlinks.spr(j)->x+=dx;
923 }
924 }
925
926 1211 x=new_x;
927
928 // A kludge
929
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1211 if(!diagonalMovement && dir<=down)
930 is_on_conveyor=true;
931 1211 }
932
933 1081 void HeroClass::setYfix(zfix new_y)
934 {
935 1081 zfix dy=new_y-y;
936 1081 justmoved = 2;
937
1/2
✓ Branch 0 taken 1081 times.
✗ Branch 1 not taken.
1081 if(Lwpns.idFirst(wHookshot)>-1)
938 {
939 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
940 hs_starty+=(int32_t)dy;
941 }
942
943
1/2
✓ Branch 0 taken 1081 times.
✗ Branch 1 not taken.
1081 if(Lwpns.idFirst(wHSHandle)>-1)
944 {
945 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
946 }
947
948
1/2
✓ Branch 0 taken 1081 times.
✗ Branch 1 not taken.
1081 if(chainlinks.Count()>0)
949 {
950 for(int32_t j=0; j<chainlinks.Count(); j++)
951 {
952 chainlinks.spr(j)->y+=dy;
953 }
954 }
955
956 1081 y=new_y;
957
958 // A kludge
959
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1081 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1081 if(!diagonalMovement && dir>=left)
960 is_on_conveyor=true;
961 1081 }
962
963 2767 void HeroClass::setZfix(zfix new_z)
964 {
965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2767 times.
2767 if(isSideViewHero())
966 return;
967
968
4/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 2754 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 7 times.
2767 if(z==0 && new_z > 0)
969 {
970
1/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 switch(action)
971 {
972 case swimming:
973 {
974 diveclk=0;
975 action=walking; FFCore.setHeroAction(walking);
976 break;
977 }
978
979 case waterhold1:
980 {
981 action=landhold1; FFCore.setHeroAction(landhold1);
982 break;
983 }
984
985 case waterhold2:
986 {
987 action=landhold2; FFCore.setHeroAction(landhold2);
988 break;
989 }
990
991 default:
992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(charging) //!DIMITODO: Let Hero jump while charging sword
993 {
994 reset_swordcharge();
995 attackclk=0;
996 }
997
998 7 break;
999 }
1000 7 }
1001
1002
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 6 times.
2767 z=(new_z>0 ? new_z : zfix(0));
1003 2767 }
1004
1005 void HeroClass::setFakeZfix(zfix new_z)
1006 {
1007 if(isSideViewHero())
1008 return;
1009
1010 if(fakez==0 && new_z > 0)
1011 {
1012 switch(action)
1013 {
1014 case swimming:
1015 {
1016 diveclk=0;
1017 action=walking; FFCore.setHeroAction(walking);
1018 break;
1019 }
1020
1021 case waterhold1:
1022 {
1023 action=landhold1; FFCore.setHeroAction(landhold1);
1024 break;
1025 }
1026
1027 case waterhold2:
1028 {
1029 action=landhold2; FFCore.setHeroAction(landhold2);
1030 break;
1031 }
1032
1033 default:
1034 if(charging) //!DIMITODO: Let Hero jump while charging sword
1035 {
1036 reset_swordcharge();
1037 attackclk=0;
1038 }
1039
1040 break;
1041 }
1042 }
1043
1044 fakez=(new_z>0 ? new_z : zfix(0));
1045 }
1046
1047 4054 void HeroClass::setFall(zfix new_fall)
1048 {
1049 4054 fall=new_fall;
1050 4054 justmoved = 2;
1051 4054 jumping=-1;
1052 4054 }
1053 void HeroClass::setFakeFall(zfix new_fall)
1054 {
1055 fakefall=new_fall;
1056 jumping=-1;
1057 }
1058 void HeroClass::setClimbCoverX(int32_t new_x)
1059 {
1060 climb_cover_x=new_x;
1061 }
1062 void HeroClass::setClimbCoverY(int32_t new_y)
1063 {
1064 climb_cover_y=new_y;
1065 }
1066 40633 int32_t HeroClass::getLStep()
1067 {
1068 40633 return lstep;
1069 }
1070 2798 int32_t HeroClass::getCharging()
1071 {
1072 2798 return charging;
1073 }
1074 46297 bool HeroClass::isCharged()
1075 {
1076 46297 return spins>0;
1077 }
1078 int32_t HeroClass::getAttackClk()
1079 {
1080 return attackclk;
1081 }
1082 void HeroClass::setAttackClk(int32_t new_clk)
1083 {
1084 attackclk=new_clk;
1085 }
1086 void HeroClass::setCharging(int32_t new_charging)
1087 {
1088 charging=new_charging;
1089 }
1090 1467690213 int32_t HeroClass::getSwordClk()
1091 {
1092 1467690213 return swordclk;
1093 }
1094 1445895498 int32_t HeroClass::getItemClk()
1095 {
1096 1445895498 return itemclk;
1097 }
1098 1 void HeroClass::setSwordClk(int32_t newclk)
1099 {
1100 1 swordclk=newclk;
1101 1 verifyAWpn();
1102 1 }
1103 1 void HeroClass::setItemClk(int32_t newclk)
1104 {
1105 1 itemclk=newclk;
1106 1 }
1107 268290 zfix HeroClass::getModifiedX()
1108 {
1109 268290 zfix tempx=x;
1110
1111
4/4
✓ Branch 0 taken 53821 times.
✓ Branch 1 taken 214469 times.
✓ Branch 2 taken 34294 times.
✓ Branch 3 taken 19527 times.
268290 if(screenscrolling&&(dir==left))
1112 {
1113 19527 tempx=tempx+256;
1114 19527 }
1115
1116 268290 return tempx;
1117 }
1118
1119 268290 zfix HeroClass::getModifiedY()
1120 {
1121 268290 zfix tempy=y;
1122
1123
4/4
✓ Branch 0 taken 53821 times.
✓ Branch 1 taken 214469 times.
✓ Branch 2 taken 13459 times.
✓ Branch 3 taken 40362 times.
268290 if(screenscrolling&&(dir==up))
1124 {
1125 13459 tempy=tempy+176;
1126 13459 }
1127
1128 268290 return tempy;
1129 }
1130
1131 6476 int32_t HeroClass::getDir()
1132 {
1133 6476 return dir;
1134 }
1135 465 void HeroClass::setDir(int32_t newdir)
1136 {
1137 465 dir=newdir;
1138 465 reset_hookshot();
1139 465 }
1140 int32_t HeroClass::getHitDir()
1141 {
1142 return hitdir;
1143 }
1144 void HeroClass::setHitDir(int32_t newdir)
1145 {
1146 hitdir = newdir;
1147 }
1148 int32_t HeroClass::getClk()
1149 {
1150 return clk;
1151 }
1152 int32_t HeroClass::getPushing()
1153 {
1154 return pushing;
1155 }
1156 4941 void HeroClass::Catch()
1157 {
1158
5/6
✓ Branch 0 taken 4941 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3696 times.
✓ Branch 3 taken 1245 times.
✓ Branch 4 taken 1997 times.
✓ Branch 5 taken 1699 times.
4941 if(!inwallm && (action==none || action==walking))
1159 {
1160 3242 SetAttack();
1161 3242 attackclk=0;
1162 3242 attack=wCatching;
1163 3242 }
1164 4941 }
1165
1166 2697917 bool HeroClass::getClock()
1167 {
1168 2697917 return superman;
1169 }
1170 488 void HeroClass::setClock(bool state)
1171 {
1172 488 superman=state;
1173 488 }
1174 22615060 int32_t HeroClass::getAction() // Used by ZScript
1175 {
1176
2/2
✓ Branch 0 taken 7632 times.
✓ Branch 1 taken 22607428 times.
22615060 if(spins > 0)
1177 7632 return isspinning;
1178
2/2
✓ Branch 0 taken 17289 times.
✓ Branch 1 taken 22590139 times.
22607428 else if(charging > 0)
1179 17289 return ischarging;
1180
2/2
✓ Branch 0 taken 22573207 times.
✓ Branch 1 taken 16932 times.
22590139 else if(diveclk > 0)
1181 16932 return isdiving;
1182 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1183
1184 22573207 return action;
1185 22615060 }
1186
1187 10137935 int32_t HeroClass::getAction2() // Used by ZScript new FFCore.actions
1188 {
1189
2/2
✓ Branch 0 taken 848 times.
✓ Branch 1 taken 10137087 times.
10137935 if(spins > 0)
1190 848 return isspinning;
1191
2/2
✓ Branch 0 taken 1921 times.
✓ Branch 1 taken 10135166 times.
10137087 else if(charging > 0)
1192 1921 return ischarging;
1193
2/2
✓ Branch 0 taken 10118400 times.
✓ Branch 1 taken 16766 times.
10135166 else if(diveclk > 0)
1194 16766 return isdiving;
1195 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1196
1197 10118400 return -1;
1198 10137935 }
1199
1200 189 void HeroClass::setAction(actiontype new_action) // Used by ZScript
1201 {
1202
4/8
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 189 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 189 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 189 times.
378 if(new_action==dying || new_action==won || new_action==scrolling ||
1203
3/6
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 189 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 189 times.
✗ Branch 5 not taken.
189 new_action==inwind || new_action==ischarging || new_action==sideswimischarging ||
1204 189 new_action==hopping) //!DIMITODO: allow setting sideswimming stuff
1205 return; // Can't use these actions.
1206
1207
2/6
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 189 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
189 if (!isSideViewHero() && (new_action>=sideswimming && new_action <= sideswimischarging))
1208 return;
1209
1210
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(new_action==rafting)
1211 {
1212 if(get_bit(quest_rules, qr_DISALLOW_SETTING_RAFTING)) return;
1213 if(!(isRaftFlag(nextflag(x+8,y+8,dir,false))||isRaftFlag(nextflag(x+8,y+8,dir,true))))
1214 return;
1215 }
1216
1217
1218
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
189 if(magicitem>-1 && itemsbuf[magicitem].family==itype_faroreswind)
1219 {
1220 // Using Farore's Wind
1221 if(magiccastclk<96)
1222 {
1223 // Not cast yet; cancel it
1224 magicitem=-1;
1225 magiccastclk=0;
1226 }
1227 else
1228 // Already activated; don't do anything
1229 return;
1230 }
1231
1232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if(action==inwind) // Remove from whirlwind
1233 {
1234 xofs=0;
1235 whirlwind=0;
1236 lstep=0;
1237 if ( dontdraw < 2 ) { dontdraw=0; }
1238 }
1239
2/4
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 189 times.
189 else if(action==freeze||action==sideswimfreeze) // Might be in enemy wind
1240 {
1241 sprite* wind=0;
1242 bool foundWind=false;
1243 for(int32_t i=0; i<Ewpns.Count(); i++)
1244 {
1245 wind=Ewpns.spr(i);
1246 if(wind->id==ewWind && wind->misc==999)
1247 {
1248 foundWind=true;
1249 break;
1250 }
1251 }
1252
1253 if(foundWind)
1254 {
1255 xofs=0;
1256 if ( dontdraw < 2 ) { dontdraw=false; }
1257 wind->misc=-1;
1258 x=wind->x;
1259 y=wind->y;
1260 }
1261 }
1262
1263 //Unless compat rule is on, reset hopping clocks when writing action!
1264
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
189 if(action == hopping && !get_bit(quest_rules,qr_NO_OVERWRITING_HOPPING))
1265 {
1266 hopclk = 0;
1267 hopdir = -1;
1268 }
1269
1270
3/4
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 65 times.
189 if(new_action != attacking && new_action != sideswimattacking)
1271 {
1272 65 attackclk=0;
1273
1274
1/2
✓ Branch 0 taken 65 times.
✗ Branch 1 not taken.
65 if(attack==wHookshot)
1275 reset_hookshot();
1276 65 }
1277
2/4
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 189 times.
189 if(new_action != isspinning && new_action != sideswimisspinning)
1278 {
1279 189 charging = 0;
1280 189 spins = 0;
1281 189 }
1282
1283
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
189 if(action == falling && new_action != falling)
1284 {
1285 fallclk = 0; //Stop falling;
1286 }
1287
1288
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
189 if (action == rafting && new_action != rafting)
1289 {
1290 raftwarpx = x;//If you wanted to make Link stop rafting on a dock combo, don't make the dock retrigger the raft.
1291 raftwarpy = y;
1292 }
1293
1294
2/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 124 times.
✓ Branch 5 taken 65 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
189 switch(new_action)
1295 {
1296 case isspinning:
1297 case sideswimisspinning:
1298 if(attack==wSword)
1299 {
1300 attackclk = SWORDCHARGEFRAME+1;
1301 charging = 0;
1302
1303 if(spins==0)
1304 spins = 5;
1305 }
1306 return;
1307
1308 case isdiving:
1309 if(action==swimming && diveclk==0)
1310 {
1311 int32_t flippers_id = current_item_id(itype_flippers);
1312 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2)); // Who cares about qr_NODIVING? It's the questmaker's business.
1313 }
1314 return;
1315
1316 case drowning:
1317 case sidedrowning:
1318 //I would add a sanity check to see if Hero is in water, but I *KNOW* that quests have used this
1319 // INTENTIONALLY while Hero is on Land, as a blink-out effect. :( -Z
1320 if(!drownclk)
1321 Drown();
1322
1323 break;
1324
1325 case lavadrowning:
1326 //Lavadrowning is just drowning but with a different argument. Simplicity! -Dimi
1327 if(!drownclk)
1328 Drown(1);
1329
1330 break;
1331
1332 case falling:
1333 if(!fallclk)
1334 {
1335 //If there is a pit under Hero, use it's combo.
1336 if(int32_t c = getpitfall(x+8,y+(bigHitbox?8:12))) fallCombo = c;
1337 else if(int32_t c = getpitfall(x,y+(bigHitbox?0:8))) fallCombo = c;
1338 else if(int32_t c = getpitfall(x+15,y+(bigHitbox?0:8))) fallCombo = c;
1339 else if(int32_t c = getpitfall(x,y+15)) fallCombo = c;
1340 else if(int32_t c = getpitfall(x+15,y+15)) fallCombo = c;
1341 //Else, use a null value; triggers default pit values
1342 else fallCombo = 0;
1343 fallclk = PITFALL_FALL_FRAMES;
1344 }
1345 break;
1346
1347 case gothit:
1348 case swimhit:
1349 case sideswimhit:
1350 if(!hclk)
1351 hclk=48;
1352
1353 break;
1354
1355 case landhold1:
1356 case landhold2:
1357 case waterhold1:
1358 case waterhold2:
1359 case sidewaterhold1:
1360 case sidewaterhold2:
1361 if(!holdclk)
1362 holdclk=130;
1363
1364 attack=none;
1365 break;
1366
1367 case attacking:
1368 case sideswimattacking:
1369 124 attack=none;
1370 124 break;
1371
1372 default:
1373 65 break;
1374 }
1375
1376 189 action=new_action; FFCore.setHeroAction(new_action);
1377 189 }
1378
1379 void HeroClass::setHeldItem(int32_t newitem)
1380 {
1381 holditem=newitem;
1382 }
1383 17 int32_t HeroClass::getHeldItem()
1384 {
1385 17 return holditem;
1386 }
1387 3220037 bool HeroClass::isDiving()
1388 {
1389 3220037 int32_t flippers_id = current_item_id(itype_flippers);
1390
2/2
✓ Branch 0 taken 2616328 times.
✓ Branch 1 taken 603709 times.
3220037 return (diveclk > (flippers_id < 0 ? 30 : itemsbuf[flippers_id].misc2));
1391 }
1392 7313394 bool HeroClass::isSwimming()
1393 {
1394
4/6
✓ Branch 0 taken 7259526 times.
✓ Branch 1 taken 53868 times.
✓ Branch 2 taken 7259526 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7259526 times.
✗ Branch 5 not taken.
14572920 return ((action==swimming)||(action==sideswimming)||IsSideSwim()||
1395
4/4
✓ Branch 0 taken 7258616 times.
✓ Branch 1 taken 910 times.
✓ Branch 2 taken 390 times.
✓ Branch 3 taken 7258226 times.
7259526 (action==waterhold1)||(action==waterhold2)||
1396 7258226 (hopclk==0xFF));
1397 }
1398
1399 535 void HeroClass::setDontDraw(byte new_dontdraw)
1400 {
1401 535 dontdraw=new_dontdraw;
1402 535 }
1403
1404 320116 byte HeroClass::getDontDraw()
1405 {
1406 320116 return dontdraw;
1407 }
1408
1409 void HeroClass::setHClk(int32_t newhclk)
1410 {
1411 hclk=newhclk;
1412 }
1413
1414 87306 int32_t HeroClass::getHClk()
1415 {
1416 87306 return hclk;
1417 }
1418
1419 1090541 int32_t HeroClass::getSpecialCave()
1420 {
1421 1090541 return specialcave; // used only by maps.cpp
1422 }
1423
1424 179 void HeroClass::init()
1425 {
1426 179 usecounts.clear();
1427 179 scale = 0;
1428 179 rotation = 0;
1429 179 do_animation = 1;
1430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 179 times.
179 if(lift_wpn)
1431 {
1432 delete lift_wpn;
1433 lift_wpn = nullptr;
1434 }
1435 179 liftclk = 0;
1436 179 tliftclk = 0;
1437 179 liftheight = 0;
1438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 179 times.
179 if ( dontdraw != 2 ) { dontdraw = 0; } //scripted dontdraw == 2, normal == 1, draw hero == 0
1439 179 hookshot_used=false;
1440 179 justmoved = 0;
1441 179 hookshot_frozen=false;
1442 179 onpassivedmg=false;
1443 179 dir = up;
1444 179 damageovertimeclk = 0;
1445 179 newconveyorclk = 0;
1446 179 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
1447
2/2
✓ Branch 0 taken 1253 times.
✓ Branch 1 taken 179 times.
1432 for(auto q = 0; q < 7; ++q)
1448 1253 hooked_undercombos[q] = -1;
1449 179 shiftdir = -1;
1450 179 sideswimdir = right;
1451 179 holddir = -1;
1452 179 landswim = 0;
1453 179 sdir = up;
1454 179 ilswim=true;
1455 179 walkable=false;
1456 179 moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL | FLAG_CAN_WATERDROWN;
1457 179 warp_sound = 0;
1458 179 subscr_speed = zinit.subscrSpeed;
1459 179 steprate = zinit.heroStep;
1460 179 is_warping = false;
1461 179 can_mirror_portal = true;
1462 179 coyotetime = 0;
1463
1464 179 hammer_swim_up_offset = hammeroffsets[0];
1465 179 hammer_swim_down_offset = hammeroffsets[1];
1466 179 hammer_swim_left_offset = hammeroffsets[2];
1467 179 hammer_swim_right_offset = hammeroffsets[3];
1468
1469 179 prompt_combo = prompt_x = prompt_y = prompt_cset = 0;
1470
1471
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 125 times.
179 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
1472 {
1473 54 x=tmpscr->warpreturnx[0];
1474 54 y=tmpscr->warpreturny[0];
1475 54 }
1476 else
1477 {
1478 125 x=tmpscr->warparrivalx;
1479 125 y=tmpscr->warparrivaly;
1480 }
1481
1482 179 z=fakez=fall=fakefall=0;
1483 179 hzsz = 12; // So that flying peahats can still hit him.
1484
1485
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 131 times.
179 if(x==0) dir=right;
1486
1487
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 178 times.
179 if(x==240) dir=left;
1488
1489
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 129 times.
179 if(y==0) dir=down;
1490
1491
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 141 times.
179 if(y==160) dir=up;
1492
1493 179 lstep=0;
1494 179 skipstep=0;
1495 179 autostep=false;
1496 179 attackclk=holdclk=hoverclk=jumping=raftclk=0;
1497 179 attack=wNone;
1498 179 attackid=-1;
1499 179 action=none; FFCore.setHeroAction(none); tempaction=none;
1500 179 xofs=0;
1501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 179 times.
179 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
1502 179 cs=6;
1503 179 pushing=fairyclk=0;
1504 179 id=0;
1505 179 inlikelike=0;
1506 179 superman=inwallm=false;
1507 179 scriptcoldet=1;
1508 179 blowcnt=whirlwind=specialcave=0;
1509 179 hopclk=diveclk=fallclk=0;
1510 179 fallCombo = 0;
1511 179 pit_pulldir = -1;
1512 179 hopdir=-1;
1513 179 conveyor_flags=0;
1514 179 drunkclk=0;
1515 179 lstunclock = 0;
1516 179 is_conveyor_stunned=0;
1517 179 drawstyle=3;
1518 179 ffwarp = false;
1519 179 stepoutindex=stepoutwr=stepoutdmap=stepoutscr=0;
1520 179 stepnext=stepsecret=-1;
1521 179 ffpit = false;
1522 179 respawn_x=x;
1523 179 respawn_y=y;
1524 179 respawn_dmap=currdmap;
1525 179 respawn_scr=currscr;
1526 179 falling_oldy = y;
1527 179 magiccastclk=0;
1528 179 magicitem = nayruitem = -1;
1529 179 last_lens_id = 0; //Should be -1 (-Z)
1530 179 last_savepoint_id = 0;
1531 179 misc_internal_hero_flags = 0;
1532 179 last_cane_of_byrna_item_id = -1;
1533 179 on_sideview_ladder = false;
1534 179 switchblock_z = 0;
1535 179 switchblock_offset = false;
1536 179 extra_jump_count = 0;
1537 179 hoverflags = 0;
1538 179 lbunnyclock = 0;
1539
1540
2/2
✓ Branch 0 taken 5728 times.
✓ Branch 1 taken 179 times.
5907 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
1541
1542 179 setBigHitbox(get_bit(quest_rules, qr_LTTPCOLLISION));
1543 179 diagonalMovement=(get_bit(quest_rules,qr_LTTPWALK));
1544
1545 179 shield_active = false;
1546 179 shield_forcedir = -1;
1547 179 active_shield_id = -1;
1548
1549 //2.6
1550 179 preventsubscreenfalling = false; //-Z
1551 179 walkspeed = 0; //not used, yet. -Z
1552
2/2
✓ Branch 0 taken 2864 times.
✓ Branch 1 taken 179 times.
3043 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][0] = 0;
1553
2/2
✓ Branch 0 taken 2864 times.
✓ Branch 1 taken 179 times.
3043 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][1] = 0;
1554
2/2
✓ Branch 0 taken 26134 times.
✓ Branch 1 taken 179 times.
26313 for ( int32_t q = 0; q < wMax; q++ )
1555 {
1556 26134 defence[q] = hero_defence[q]; //we will need to have a Hero section in the quest load/save code! -Z Added 3/26/21 - Jman
1557 //zprint2("defence[%d] is: %d\n", q, defence[q]);
1558 26134 }
1559 //Run script!
1560
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 152 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 13 times.
179 if (( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 ) && (game->get_hasplayed()) ) //if (!hasplayed) runs in game_loop()
1561 {
1562 14 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_INIT, SCRIPT_PLAYER_INIT);
1563 14 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_INIT);
1564 14 FFCore.initZScriptHeroScripts(); //Clear the stack and the refinfo data to be ready for Hero's active script.
1565 14 set_respawn_point(); //screen entry at spawn; //This should be after the init script, so that Hero->X and Hero->Y set by the script
1566 //are properly set by the engine.
1567 14 }
1568 179 FFCore.nostepforward = 0;
1569 179 }
1570
1571 3897961 void HeroClass::draw_under(BITMAP* dest)
1572 {
1573 3897961 int32_t c_raft=current_item_id(itype_raft);
1574 3897961 int32_t c_ladder=current_item_id(itype_ladder);
1575
1576
3/4
✓ Branch 0 taken 26984 times.
✓ Branch 1 taken 3870977 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26984 times.
3897961 if(action==rafting && c_raft >-1)
1577 {
1578
4/4
✓ Branch 0 taken 19335 times.
✓ Branch 1 taken 7649 times.
✓ Branch 2 taken 17507 times.
✓ Branch 3 taken 9477 times.
26984 if(((dir==left) || (dir==right)) && (get_bit(quest_rules,qr_RLFIX)))
1579 {
1580 18954 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1581 9477 itemsbuf[c_raft].csets&15, rotate_value((itemsbuf[c_raft].misc_flags>>2)&3)^3);
1582 9477 }
1583 else
1584 {
1585 35014 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1586 17507 itemsbuf[c_raft].csets&15, (itemsbuf[c_raft].misc_flags>>2)&3);
1587 }
1588 26984 }
1589
1590
3/4
✓ Branch 0 taken 51582 times.
✓ Branch 1 taken 3846379 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 51582 times.
3897961 if(ladderx+laddery && c_ladder >-1)
1591 {
1592
4/4
✓ Branch 0 taken 24599 times.
✓ Branch 1 taken 26983 times.
✓ Branch 2 taken 6232 times.
✓ Branch 3 taken 18367 times.
51582 if((ladderdir>=left) && (get_bit(quest_rules,qr_RLFIX)))
1593 {
1594 12464 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1595 6232 itemsbuf[c_ladder].csets&15, rotate_value((itemsbuf[iRaft].misc_flags>>2)&3)^3);
1596 6232 }
1597 else
1598 {
1599 90700 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1600 45350 itemsbuf[c_ladder].csets&15, (itemsbuf[c_ladder].misc_flags>>2)&3);
1601 }
1602 51582 }
1603 3897961 }
1604
1605 3357 void HeroClass::drawshadow(BITMAP* dest, bool translucent)
1606 {
1607 3357 int32_t tempy=yofs;
1608 3357 yofs+=8;
1609 3357 shadowtile = wpnsbuf[spr_shadow].tile;
1610 3357 sprite::drawshadow(dest,translucent);
1611 3357 yofs=tempy;
1612 3357 }
1613
1614 // The Stone of Agony reacts to these flags.
1615 465328 bool HeroClass::agonyflag(int32_t flag)
1616 {
1617
2/2
✓ Branch 0 taken 465296 times.
✓ Branch 1 taken 32 times.
465328 switch(flag)
1618 {
1619 case mfWHISTLE:
1620 case mfBCANDLE:
1621 case mfARROW:
1622 case mfBOMB:
1623 case mfSBOMB:
1624 case mfBRANG:
1625 case mfMBRANG:
1626 case mfFBRANG:
1627 case mfSARROW:
1628 case mfGARROW:
1629 case mfRCANDLE:
1630 case mfWANDFIRE:
1631 case mfDINSFIRE:
1632 case mfWANDMAGIC:
1633 case mfREFMAGIC:
1634 case mfREFFIREBALL:
1635 case mfSWORD:
1636 case mfWSWORD:
1637 case mfMSWORD:
1638 case mfXSWORD:
1639 case mfSWORDBEAM:
1640 case mfWSWORDBEAM:
1641 case mfMSWORDBEAM:
1642 case mfXSWORDBEAM:
1643 case mfHOOKSHOT:
1644 case mfWAND:
1645 case mfHAMMER:
1646 case mfSTRIKE:
1647 32 return true;
1648 }
1649
1650 465296 return false;
1651 465328 }
1652
1653
1654 // Find the attack power of the current melee weapon.
1655 // The Whimsical Ring is applied on a target-by-target basis.
1656 314506 int32_t HeroClass::weaponattackpower(int32_t itid)
1657 {
1658
1/2
✓ Branch 0 taken 314506 times.
✗ Branch 1 not taken.
314506 if(itid < 0)
1659 {
1660 itid = current_item_id(attack==wCByrna ? itype_cbyrna
1661 : attack==wWand ? itype_wand
1662 : attack==wHammer ? itype_hammer
1663 : itype_sword);
1664 }
1665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 314506 times.
314506 int32_t power = attack==wCByrna ? itemsbuf[itid].misc4 : itemsbuf[itid].power;
1666
1667 // Multiply it by the power of the spin attack/quake hammer, if applicable.
1668
5/6
✓ Branch 0 taken 313932 times.
✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 574 times.
✓ Branch 4 taken 443 times.
✓ Branch 5 taken 131 times.
314506 power *= (spins>0 ? itemsbuf[current_item_id(attack==wHammer ? itype_quakescroll : (spins>5 || current_item_id(itype_spinscroll) < 0) ? itype_spinscroll2 : itype_spinscroll)].power : 1);
1669 314506 return power;
1670 }
1671
1672 #define NET_CLK_TOTAL 24
1673 #define NET_DIR_INC (NET_CLK_TOTAL/3)
1674 // Must only be called once per frame!
1675 void HeroClass::positionNet(weapon *w, int32_t itemid)
1676 {
1677 itemid = vbound(itemid, 0, MAXITEMS-1);
1678 int32_t t = w->o_tile,
1679 wx = 1, wy = 1;
1680
1681 //Invert positioning clock if right-handed animation
1682 int32_t clock = (itemsbuf[itemid].flags&ITEM_FLAG2 ? (NET_CLK_TOTAL-1)-attackclk : attackclk);
1683 if(clock >= NET_CLK_TOTAL)
1684 w->dead = 0;
1685 int32_t tiledir = dir;
1686 switch(dir)
1687 {
1688 case up:
1689 {
1690 if(clock < NET_DIR_INC) tiledir = l_up;
1691 else if(clock >= NET_DIR_INC*2) tiledir = r_up;
1692 break;
1693 }
1694 case down:
1695 {
1696 if(clock < NET_DIR_INC) tiledir = r_down;
1697 else if(clock >= NET_DIR_INC*2) tiledir = l_down;
1698 break;
1699 }
1700 case left:
1701 {
1702 if(clock < NET_DIR_INC) tiledir = l_down;
1703 else if(clock >= NET_DIR_INC*2) tiledir = l_up;
1704 break;
1705 }
1706 case right:
1707 {
1708 if(clock < NET_DIR_INC) tiledir = r_up;
1709 else if(clock >= NET_DIR_INC*2) tiledir = r_down;
1710 break;
1711 }
1712 }
1713 int32_t offs = 0;
1714 if(tiledir > right)
1715 offs = ((clock%NET_DIR_INC)<NET_DIR_INC/2) ? 1 : 0;
1716 else offs = vbound(((clock%NET_DIR_INC)/(NET_DIR_INC/3))-1,-1,1);
1717 //One of 8 positions
1718 switch(tiledir)
1719 {
1720 case up:
1721 {
1722 wx = 6*offs;
1723 wy = -14;
1724 break;
1725 }
1726 case r_up:
1727 {
1728 wx = (offs ? 10 : 14);
1729 wy = (offs ? -12 : -10);
1730 break;
1731 }
1732 case right:
1733 {
1734 wx = 14;
1735 wy = 6*offs;
1736 break;
1737 }
1738 case r_down:
1739 {
1740 wx = (offs ? 14 : 10);
1741 wy = (offs ? 10 : 12);
1742 break;
1743 }
1744 case down:
1745 {
1746 wx = -6*offs;
1747 wy = 14;
1748 break;
1749 }
1750 case l_down:
1751 {
1752 wx = (offs ? -10 : -14);
1753 wy = (offs ? 12 : 10);
1754 break;
1755 }
1756 case left:
1757 {
1758 wx = -14;
1759 wy = -6*offs;
1760 break;
1761 }
1762 case l_up:
1763 {
1764 wx = (offs ? -14 : -10);
1765 wy = (offs ? -10 : -12);
1766 break;
1767 }
1768 }
1769
1770 w->x = x+wx;
1771 w->y = y+wy-(54-(yofs))-fakez;
1772 w->z = (z+zofs);
1773 w->fakez = fakez;
1774 w->tile = t+tiledir;
1775 w->power = 0;
1776 w->dir = dir;
1777 w->doAutoRotate(true);
1778 }
1779 288206 void HeroClass::positionSword(weapon *w, int32_t itemid)
1780 {
1781 //if ( w->ScriptGenerated ) return; //t/b/a for script-generated swords.
1782 //if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
1783 288206 itemid=vbound(itemid, 0, MAXITEMS-1);
1784 // Place a sword weapon at the right spot.
1785 288206 int32_t wy=1;
1786 288206 int32_t wx=1;
1787 288206 int32_t f=0,t,cs2;
1788
1789 288206 t = w->o_tile;
1790 288206 cs2 = w->o_cset;
1791 288206 slashxofs=0;
1792 288206 slashyofs=0;
1793
1794
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 62743 times.
✓ Branch 2 taken 63673 times.
✓ Branch 3 taken 81810 times.
✓ Branch 4 taken 79980 times.
288206 switch(dir)
1795 {
1796 case up:
1797 62743 wx=-1;
1798 62743 wy=-12;
1799
1800
6/8
✓ Branch 0 taken 5150 times.
✓ Branch 1 taken 57593 times.
✓ Branch 2 taken 4107 times.
✓ Branch 3 taken 1043 times.
✓ Branch 4 taken 4107 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 4107 times.
62743 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1801 {
1802
2/2
✓ Branch 0 taken 2689 times.
✓ Branch 1 taken 1418 times.
4107 if(attackclk>10) //extended stab
1803 {
1804 1418 slashyofs-=3;
1805 1418 wy-=2;
1806 1418 }
1807
1808
2/2
✓ Branch 0 taken 3751 times.
✓ Branch 1 taken 356 times.
4107 if(attackclk>=14) //retracting stab
1809 {
1810 356 slashyofs+=3;
1811 356 wy+=2;
1812 356 }
1813 4107 }
1814 else
1815 {
1816
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 58350 times.
58636 if(attackclk==SWORDCHARGEFRAME)
1817 {
1818 286 wy+=4;
1819 286 }
1820
2/2
✓ Branch 0 taken 5643 times.
✓ Branch 1 taken 52707 times.
58350 else if(attackclk==13)
1821 {
1822 5643 wy+=4;
1823 5643 }
1824
2/2
✓ Branch 0 taken 47158 times.
✓ Branch 1 taken 5549 times.
52707 else if(attackclk==14)
1825 {
1826 5549 wy+=8;
1827 5549 }
1828 }
1829
1830 62743 break;
1831
1832 case down:
1833 63673 f=get_bit(quest_rules,qr_SWORDWANDFLIPFIX)?3:2;
1834 63673 wy=11;
1835
1836
6/8
✓ Branch 0 taken 6974 times.
✓ Branch 1 taken 56699 times.
✓ Branch 2 taken 6227 times.
✓ Branch 3 taken 747 times.
✓ Branch 4 taken 6227 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6227 times.
63673 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1837 {
1838
2/2
✓ Branch 0 taken 4040 times.
✓ Branch 1 taken 2187 times.
6227 if(attackclk>10) //extended stab
1839 {
1840 2187 slashyofs+=3;
1841 2187 wy+=2;
1842 2187 }
1843
1844
2/2
✓ Branch 0 taken 5689 times.
✓ Branch 1 taken 538 times.
6227 if(attackclk>=14) //retracting stab
1845 {
1846 538 slashyofs-=3;
1847 538 wy-=2;
1848 538 }
1849 6227 }
1850 else
1851 {
1852
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 56846 times.
57446 if(attackclk==SWORDCHARGEFRAME)
1853 {
1854 600 wy-=2;
1855 600 }
1856
2/2
✓ Branch 0 taken 5564 times.
✓ Branch 1 taken 51282 times.
56846 else if(attackclk==13)
1857 {
1858 5564 wy-=4;
1859 5564 }
1860
2/2
✓ Branch 0 taken 45743 times.
✓ Branch 1 taken 5539 times.
51282 else if(attackclk==14)
1861 {
1862 5539 wy-=8;
1863 5539 }
1864 }
1865
1866 63673 break;
1867
1868 case left:
1869 81810 f=1;
1870 81810 wx=-11;
1871 81810 ++t;
1872
1873
6/8
✓ Branch 0 taken 8650 times.
✓ Branch 1 taken 73160 times.
✓ Branch 2 taken 6332 times.
✓ Branch 3 taken 2318 times.
✓ Branch 4 taken 6332 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6332 times.
81810 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1874 {
1875
2/2
✓ Branch 0 taken 4060 times.
✓ Branch 1 taken 2272 times.
6332 if(attackclk>10) //extended stab
1876 {
1877 2272 slashxofs-=4;
1878 2272 wx-=7;
1879 2272 }
1880
1881
2/2
✓ Branch 0 taken 5769 times.
✓ Branch 1 taken 563 times.
6332 if(attackclk>=14) //retracting stab
1882 {
1883 563 slashxofs+=3;
1884 563 wx+=7;
1885 563 }
1886 6332 }
1887 else
1888 {
1889
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 75275 times.
75478 if(attackclk==SWORDCHARGEFRAME)
1890 {
1891 203 wx+=2;
1892 203 }
1893
2/2
✓ Branch 0 taken 7402 times.
✓ Branch 1 taken 67873 times.
75275 else if(attackclk==13)
1894 {
1895 7402 wx+=4;
1896 7402 }
1897
2/2
✓ Branch 0 taken 60502 times.
✓ Branch 1 taken 7371 times.
67873 else if(attackclk==14)
1898 {
1899 7371 wx+=8;
1900 7371 }
1901 }
1902
1903 81810 break;
1904
1905 case right:
1906 79980 wx=11;
1907 79980 ++t;
1908
1909
6/8
✓ Branch 0 taken 7024 times.
✓ Branch 1 taken 72956 times.
✓ Branch 2 taken 5177 times.
✓ Branch 3 taken 1847 times.
✓ Branch 4 taken 5177 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5177 times.
✗ Branch 7 not taken.
79980 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1910 {
1911
2/2
✓ Branch 0 taken 3291 times.
✓ Branch 1 taken 1886 times.
5177 if(attackclk>10) //extended stab
1912 {
1913 1886 slashxofs+=4;
1914 1886 wx+=7;
1915 1886 }
1916
1917
2/2
✓ Branch 0 taken 4705 times.
✓ Branch 1 taken 472 times.
5177 if(attackclk>=14) //retracting stab
1918 {
1919 472 slashxofs-=3;
1920 472 wx-=7;
1921 472 }
1922 5177 }
1923 else
1924 {
1925
2/2
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 74208 times.
74803 if(attackclk==SWORDCHARGEFRAME)
1926 {
1927 595 wx-=2;
1928 595 }
1929
2/2
✓ Branch 0 taken 7287 times.
✓ Branch 1 taken 66921 times.
74208 else if(attackclk==13)
1930 {
1931 7287 wx-=4;
1932 7287 }
1933
2/2
✓ Branch 0 taken 59656 times.
✓ Branch 1 taken 7265 times.
66921 else if(attackclk==14)
1934 {
1935 7265 wx-=8;
1936 7265 }
1937 }
1938
1939 79980 break;
1940 }
1941
1942
6/6
✓ Branch 0 taken 27798 times.
✓ Branch 1 taken 260408 times.
✓ Branch 2 taken 21843 times.
✓ Branch 3 taken 5955 times.
✓ Branch 4 taken 7763 times.
✓ Branch 5 taken 14080 times.
288206 if(game->get_canslash() && itemsbuf[itemid].flags & ITEM_FLAG4 && attackclk<11)
1943 {
1944 14080 int32_t wpn2=itemsbuf[itemid].wpn2;
1945 14080 wpn2=vbound(wpn2, 0, MAXWPNS);
1946
1947 //slashing tiles
1948
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2689 times.
✓ Branch 2 taken 4040 times.
✓ Branch 3 taken 4060 times.
✓ Branch 4 taken 3291 times.
14080 switch(dir)
1949 {
1950 case up:
1951 2689 wx=15;
1952 2689 wy=-3;
1953 2689 ++t;
1954 2689 f=0; //starts pointing right
1955
1956
2/2
✓ Branch 0 taken 1204 times.
✓ Branch 1 taken 1485 times.
2689 if(attackclk>=7)
1957 {
1958 1485 wy-=9;
1959 1485 wx-=3;
1960 1485 t = wpnsbuf[wpn2].tile;
1961 1485 cs2 = wpnsbuf[wpn2].csets&15;
1962 1485 f=0;
1963 1485 }
1964
1965 2689 break;
1966
1967 case down:
1968 4040 wx=-13;
1969 4040 wy=-1;
1970 4040 ++t;
1971 4040 f=1; //starts pointing left
1972
1973
2/2
✓ Branch 0 taken 1762 times.
✓ Branch 1 taken 2278 times.
4040 if(attackclk>=7)
1974 {
1975 2278 wy+=15;
1976 2278 wx+=2;
1977 2278 t = wpnsbuf[wpn2].tile;
1978 2278 cs2 = wpnsbuf[wpn2].csets&15;
1979 2278 ++t;
1980 2278 f=0;
1981 2278 }
1982
1983 4040 break;
1984
1985 case left:
1986 4060 wx=3;
1987 4060 wy=-15;
1988 4060 --t;
1989 4060 f=0; //starts pointing up
1990
1991
2/2
✓ Branch 0 taken 1748 times.
✓ Branch 1 taken 2312 times.
4060 if(attackclk>=7)
1992 {
1993 2312 wx-=15;
1994 2312 wy+=3;
1995 2312 slashxofs-=1;
1996 2312 t = wpnsbuf[wpn2].tile;
1997 2312 cs2 = wpnsbuf[wpn2].csets&15;
1998 2312 t+=2;
1999 2312 f=0;
2000 2312 }
2001
2002 4060 break;
2003
2004 case right:
2005 3291 --t;
2006
2007
2/4
✓ Branch 0 taken 3291 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3291 times.
3291 if(spins>0 || (itemsbuf[itemid].flags & ITEM_FLAG8))
2008 {
2009 wx=1;
2010 wy=13;
2011 f=2;
2012 }
2013 else
2014 {
2015 3291 wx=3;
2016 3291 wy=-15;
2017 3291 f=0;
2018 }
2019
2020
2/2
✓ Branch 0 taken 1416 times.
✓ Branch 1 taken 1875 times.
3291 if(attackclk>=7)
2021 {
2022 1875 wx+=15;
2023 1875 slashxofs+=1;
2024 1875 t = wpnsbuf[wpn2].tile;
2025 1875 cs2 = wpnsbuf[wpn2].csets&15;
2026
2027
2/4
✓ Branch 0 taken 1875 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1875 times.
1875 if(spins>0 || (itemsbuf[itemid].flags & ITEM_FLAG8))
2028 {
2029 wx-=1;
2030 wy-=2;
2031 }
2032 else
2033 {
2034 1875 t+=3;
2035 1875 f=0;
2036 1875 wy+=3;
2037 }
2038 1875 }
2039
2040 3291 break;
2041 }
2042 14080 }
2043
2044 288206 int32_t itemid2 = current_item_id(itype_chargering);
2045
2046
4/4
✓ Branch 0 taken 21482 times.
✓ Branch 1 taken 266724 times.
✓ Branch 2 taken 287674 times.
✓ Branch 3 taken 532 times.
288206 if(charging>(itemid2>=0 ? itemsbuf[itemid2].misc1 : 64))
2047 {
2048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 cs2=(BSZ ? (frame&3)+6 : ((frame>>2)&1)+7);
2049 532 }
2050
2051 /*if(BSZ || ((isdungeon() && currscr<128) && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)))
2052 {
2053 wy+=2;
2054 }*/
2055 288206 w->x = x+wx;
2056 288206 w->y = y+wy-(54-(yofs+slashyofs))-fakez;
2057 288206 w->z = (z+zofs);
2058 288206 w->tile = t;
2059 288206 w->flip = f;
2060 288206 w->power = weaponattackpower(itemid);
2061 288206 w->dir = dir;
2062 288206 w->doAutoRotate(true);
2063 288206 }
2064
2065 3918333 void HeroClass::draw(BITMAP* dest)
2066 {
2067 /*{
2068 char buf[36];
2069 //sprintf(buf,"%d %d %d %d %d %d %d",dir, action, attack, attackclk, charging, spins, tapping);
2070 textout_shadowed_ex(framebuf,font, buf, 2,72,WHITE,BLACK,-1);
2071 }*/
2072 int32_t oxofs, oyofs;
2073 3918333 bool shieldModify = false;
2074
2/2
✓ Branch 0 taken 3909572 times.
✓ Branch 1 taken 8761 times.
3918333 bool invisible=(dontdraw>0) || (tmpscr->flags3&fINVISHERO);
2075
2076
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 3917553 times.
3918333 if(action==dying)
2077 {
2078
2/2
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 182 times.
780 if(!invisible)
2079 {
2080
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2081 182 sprite::draw(dest);
2082 182 }
2083 780 return;
2084 }
2085
2086 3917553 bool useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2087
2088 3917553 oxofs=xofs;
2089 3917553 oyofs=yofs;
2090
2091
2/2
✓ Branch 0 taken 17671 times.
✓ Branch 1 taken 3899882 times.
3917553 if(!invisible)
2092
6/6
✓ Branch 0 taken 3591222 times.
✓ Branch 1 taken 308660 times.
✓ Branch 2 taken 2584484 times.
✓ Branch 3 taken 1006738 times.
✓ Branch 4 taken 129761 times.
✓ Branch 5 taken 2454723 times.
3899882 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2093
2094 // Stone of Agony
2095 3917553 bool agony=false;
2096 3917553 int32_t agonyid = current_item_id(itype_agony);
2097
2098
2/2
✓ Branch 0 taken 17671 times.
✓ Branch 1 taken 3899882 times.
3917553 if(invisible)
2099 17671 goto attack;
2100
2101
2/2
✓ Branch 0 taken 3667210 times.
✓ Branch 1 taken 232672 times.
3899882 if(agonyid>-1)
2102 {
2103 232672 int32_t power=itemsbuf[agonyid].power;
2104 232672 int32_t left=static_cast<int32_t>(x+8-power)&0xF0; // Check top-left pixel of each tile
2105 232672 int32_t right=(static_cast<int32_t>(x+8+power)&0xF0)+16;
2106 232672 int32_t top=static_cast<int32_t>(y+(bigHitbox ? 8 : 12)-power)&0xF0;
2107 232672 int32_t bottom=(static_cast<int32_t>(y+(bigHitbox ? 8 : 12)+power)&0xF0)+16;
2108
2109
2/2
✓ Branch 0 taken 232672 times.
✓ Branch 1 taken 232672 times.
465344 for(int32_t x=left; x<right; x+=16)
2110 {
2111
2/2
✓ Branch 0 taken 232640 times.
✓ Branch 1 taken 232672 times.
465312 for(int32_t y=top; y<bottom; y+=16)
2112 {
2113
4/4
✓ Branch 0 taken 232656 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 232640 times.
232672 if(agonyflag(MAPFLAG(x, y)) || agonyflag(MAPCOMBOFLAG(x, y)))
2114 {
2115 32 agony=true;
2116 32 x=right; // Break out of outer loop
2117 32 break;
2118 }
2119 232640 }
2120 232672 }
2121 232672 }
2122
2123 3899882 cs = 6;
2124
1/2
✓ Branch 0 taken 3899882 times.
✗ Branch 1 not taken.
3899882 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2125
2/2
✓ Branch 0 taken 1301062 times.
✓ Branch 1 taken 2598820 times.
6498702 if(!get_bit(quest_rules,qr_HEROFLICKER))
2126 {
2127
3/4
✓ Branch 0 taken 55980 times.
✓ Branch 1 taken 2542840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 55980 times.
2598820 if(superman && getCanFlicker())
2128 {
2129 55980 cs += (((~frame)>>1)&3);
2130 55980 }
2131
4/6
✓ Branch 0 taken 121524 times.
✓ Branch 1 taken 2421316 times.
✓ Branch 2 taken 121524 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 121524 times.
2542840 else if(hclk&&(NayrusLoveShieldClk<=0) && getCanFlicker())
2132 {
2133 121524 cs += ((hclk>>1)&3);
2134 121524 }
2135 2598820 }
2136
2137 attack:
2138
2139
5/6
✓ Branch 0 taken 3407556 times.
✓ Branch 1 taken 509997 times.
✓ Branch 2 taken 3404269 times.
✓ Branch 3 taken 3287 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3404269 times.
3917553 if(attackclk || (action==attacking||action==sideswimattacking))
2140 {
2141 /* Spaghetti code constants!
2142 * - Hero.attack contains a weapon type...
2143 * - which must be converted to an itype...
2144 * - which must be converted to an item ID...
2145 * - which is used to acquire a wpn ID! Aack!
2146 */
2147
7/8
✓ Branch 0 taken 10523 times.
✓ Branch 1 taken 502761 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 502761 times.
✓ Branch 4 taken 16780 times.
✓ Branch 5 taken 485981 times.
✓ Branch 6 taken 2539 times.
✓ Branch 7 taken 483442 times.
513284 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : attack==wBugNet ? itype_bugnet : itype_sword);
2148
4/4
✓ Branch 0 taken 11954 times.
✓ Branch 1 taken 501330 times.
✓ Branch 2 taken 907 times.
✓ Branch 3 taken 11047 times.
513284 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
2149 513284 itemid=vbound(itemid, 0, MAXITEMS-1);
2150 // if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
2151
7/8
✓ Branch 0 taken 162984 times.
✓ Branch 1 taken 350300 times.
✓ Branch 2 taken 162984 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 113235 times.
✓ Branch 5 taken 49749 times.
✓ Branch 6 taken 8252 times.
✓ Branch 7 taken 104983 times.
513284 if(attackclk>4||attack==wBugNet||(attack==wSword&&game->get_canslash()))
2152 {
2153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 358552 times.
358552 if(attack == wBugNet)
2154 {
2155 weapon *w=NULL;
2156 bool found = false;
2157 for(int32_t q = 0; q < Lwpns.Count(); ++q)
2158 {
2159 w = (weapon*)Lwpns.spr(q);
2160 if(w->id == wBugNet)
2161 {
2162 found = true;
2163 break;
2164 }
2165 }
2166 if(!found)
2167 {
2168 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wBugNet,0,0,dir,itemid,getUID(),false,false,true));
2169
2170 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2171 }
2172 positionNet(w, itemid);
2173 }
2174
8/8
✓ Branch 0 taken 76091 times.
✓ Branch 1 taken 282461 times.
✓ Branch 2 taken 64107 times.
✓ Branch 3 taken 11984 times.
✓ Branch 4 taken 56880 times.
✓ Branch 5 taken 7227 times.
✓ Branch 6 taken 64107 times.
✓ Branch 7 taken 294445 times.
358552 else if((attack==wSword || attack==wWand || ((attack==wFire || attack==wCByrna) && itemsbuf[itemid].wpn)) && wpnsbuf[itemsbuf[itemid].wpn].tile)
2175 {
2176 // Create a sword weapon at the right spot.
2177 294445 weapon *w=NULL;
2178 294445 bool found = false;
2179
2180 // Look for pre-existing sword
2181
2/2
✓ Branch 0 taken 28666 times.
✓ Branch 1 taken 343418 times.
372084 for(int32_t i=0; i<Lwpns.Count(); i++)
2182 {
2183 343418 w = (weapon*)Lwpns.spr(i);
2184
2185
2/2
✓ Branch 0 taken 77639 times.
✓ Branch 1 taken 265779 times.
343418 if(w->id == (attack==wSword ? wSword : wWand))
2186 {
2187 265779 found = true;
2188 265779 break;
2189 }
2190 77639 }
2191
2192
2/2
✓ Branch 0 taken 265779 times.
✓ Branch 1 taken 28666 times.
294445 if(!found) // Create one if sword nonexistant
2193 {
2194
5/10
✓ Branch 0 taken 28666 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28666 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 28666 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 28666 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 28666 times.
✗ Branch 9 not taken.
28666 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,(attack==wSword ? wSword : wWand),0,0,dir,itemid,getUID(),false,false,true));
2195 28666 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2196
2197 28666 positionSword(w,itemid);
2198
2199 // Stone of Agony
2200
1/2
✓ Branch 0 taken 28666 times.
✗ Branch 1 not taken.
28666 if(agony)
2201 {
2202 w->y-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,2))?1:0;
2203 }
2204 28666 }
2205
2206 // These are set by positionSword(), above or in checkstab()
2207 294445 yofs += slashyofs;
2208 294445 xofs += slashxofs;
2209 294445 slashyofs = slashxofs = 0;
2210 294445 }
2211 358552 }
2212
2213 513284 if(attackclk<7
2214
4/4
✓ Branch 0 taken 274122 times.
✓ Branch 1 taken 239162 times.
✓ Branch 2 taken 218481 times.
✓ Branch 3 taken 55641 times.
513284 || (attack==wSword && ((attackclk<(game->get_canslash()?15:13)
2215
4/6
✓ Branch 0 taken 51413 times.
✓ Branch 1 taken 167068 times.
✓ Branch 2 taken 51413 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 51413 times.
218481 || FIXED_Z3_ANIMATION && attackclk<(game->get_canslash()?16:12))
2216
2/2
✓ Branch 0 taken 1813 times.
✓ Branch 1 taken 49600 times.
51413 || (charging>0 && attackclk!=SWORDCHARGEFRAME)))
2217
4/4
✓ Branch 0 taken 97273 times.
✓ Branch 1 taken 7968 times.
✓ Branch 2 taken 91694 times.
✓ Branch 3 taken 5579 times.
107054 || ((attack==wWand || attack==wFire || attack==wCByrna) && attackclk<13)
2218
4/4
✓ Branch 0 taken 9900 times.
✓ Branch 1 taken 95341 times.
✓ Branch 2 taken 2029 times.
✓ Branch 3 taken 93312 times.
105241 || (attack==wHammer && attackclk<=30)
2219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93312 times.
95341 || (attack==wBugNet && attackclk<NET_CLK_TOTAL))
2220 {
2221
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 419964 times.
419972 if(!invisible)
2222 {
2223 419964 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimstab:ls_stab, dir, zinit.heroAnimationStyle);
2224
2/4
✓ Branch 0 taken 419964 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 419964 times.
✗ Branch 3 not taken.
419964 if (FIXED_Z3_ANIMATION)
2225 {
2226 if (attackclk >= 2) tile += (extend==2?2:1);
2227 if (attackclk >= 13) tile += (extend==2?2:1);
2228 }
2229
2230
14/18
✓ Branch 0 taken 40392 times.
✓ Branch 1 taken 379572 times.
✓ Branch 2 taken 12377 times.
✓ Branch 3 taken 28015 times.
✓ Branch 4 taken 5157 times.
✓ Branch 5 taken 7220 times.
✓ Branch 6 taken 4434 times.
✓ Branch 7 taken 723 times.
✓ Branch 8 taken 28015 times.
✓ Branch 9 taken 12377 times.
✓ Branch 10 taken 15706 times.
✓ Branch 11 taken 12309 times.
✓ Branch 12 taken 15706 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 15706 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
419964 if(((game->get_canslash() && (attack==wSword || attack==wWand || attack==wFire || attack==wCByrna)) && itemsbuf[itemid].flags&ITEM_FLAG4 && (attackclk<7||FIXED_Z3_ANIMATION&&(attackclk < 16))))
2231 {
2232 12309 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2233
2/4
✓ Branch 0 taken 12309 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12309 times.
✗ Branch 3 not taken.
12309 if (FIXED_Z3_ANIMATION)
2234 {
2235 if (attackclk >= 7) tile += (extend==2?2:1);
2236 if (attackclk >= 11) tile += (extend==2?2:1);
2237 if (attackclk >= 14) tile += (extend==2?2:1);
2238 }
2239 12309 }
2240
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 419964 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
419964 if (attack==wBugNet && !get_bit(quest_rules, qr_OLD_BUG_NET))
2241 {
2242 if ((dir == right && (itemsbuf[itemid].flags&ITEM_FLAG2)) || (dir != right && !(itemsbuf[itemid].flags&ITEM_FLAG2)))
2243 {
2244 if (attackclk < 9) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2245 if (attackclk > 15) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2246 }
2247 else
2248 {
2249 if (attackclk < 9) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2250 if (attackclk > 15) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2251 }
2252 }
2253
2254
4/4
✓ Branch 0 taken 2539 times.
✓ Branch 1 taken 417425 times.
✓ Branch 2 taken 1512 times.
✓ Branch 3 taken 1027 times.
419964 if((attack==wHammer) && (attackclk<13))
2255 {
2256 1027 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimpound:ls_pound, dir, zinit.heroAnimationStyle);
2257
2/4
✓ Branch 0 taken 1027 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1027 times.
✗ Branch 3 not taken.
1027 if (FIXED_Z3_ANIMATION)
2258 {
2259 if (attackclk >= 14) tile += (extend==2?2:1);
2260 if (attackclk >= 16) tile += (extend==2?2:1);
2261 }
2262 1027 }
2263
2264
2/2
✓ Branch 0 taken 396035 times.
✓ Branch 1 taken 23929 times.
419964 if(useltm)
2265 {
2266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23929 times.
23929 if ( script_hero_sprite <= 0 ) tile+=getTileModifier();
2267 23929 }
2268
2269 // Stone of Agony
2270
1/2
✓ Branch 0 taken 419964 times.
✗ Branch 1 not taken.
419964 if(agony)
2271 {
2272 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2273 }
2274
2275 //Probably what makes Hero flicker, except for the QR check. What makes him flicker when that rule is off?! -Z
2276
2277 //I'm pretty sure he doesn't flicker when the rule is off. Also, take note of the parenthesis after the ! in this if statement; I was blind and didn't see it, and thought this code did something completely different. -Deedee
2278
6/6
✓ Branch 0 taken 137706 times.
✓ Branch 1 taken 282258 times.
✓ Branch 2 taken 134100 times.
✓ Branch 3 taken 3606 times.
✓ Branch 4 taken 11476 times.
✓ Branch 5 taken 126230 times.
419964 if (!(get_bit(quest_rules, qr_HEROFLICKER) && ((superman || hclk) && (frame & 1))))
2279 {
2280 408488 masked_draw(dest);
2281 408488 }
2282
2283 //Prevent flickering -Z
2284
1/2
✓ Branch 0 taken 419964 times.
✗ Branch 1 not taken.
419964 if (!getCanFlicker()) masked_draw(dest);
2285 419964 }
2286
2287
2/2
✓ Branch 0 taken 417433 times.
✓ Branch 1 taken 2539 times.
419972 if(attack!=wHammer)
2288 {
2289 417433 xofs=oxofs;
2290 417433 yofs=oyofs;
2291 417433 return;
2292 }
2293 2539 }
2294
2295
2/2
✓ Branch 0 taken 2539 times.
✓ Branch 1 taken 93312 times.
95851 if(attack==wHammer) // To do: possibly abstract this out to a positionHammer routine?
2296 {
2297 2539 int32_t wy=1;
2298 2539 int32_t wx=1;
2299 2539 int32_t f=0,t,cs2;
2300 2539 weapon *w=NULL;
2301 2539 bool found = false;
2302
2303
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 2454 times.
2539 for(int32_t i=0; i<Lwpns.Count(); i++)
2304 {
2305 2454 w = (weapon*)Lwpns.spr(i);
2306
2307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2454 times.
2454 if(w->id == wHammer)
2308 {
2309 2454 found = true;
2310 2454 break;
2311 }
2312 }
2313
2314
2/2
✓ Branch 0 taken 2454 times.
✓ Branch 1 taken 85 times.
2539 if(!found)
2315 {
2316
5/10
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 85 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 85 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 85 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 85 times.
✗ Branch 9 not taken.
85 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wHammer,0,0,dir,itemid,getUID(),false,false,true));
2317 85 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2318 85 found = true;
2319 85 }
2320
2321 2539 t = w->o_tile;
2322 2539 cs2 = w->o_cset;
2323
2324
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 788 times.
✓ Branch 2 taken 510 times.
✓ Branch 3 taken 63 times.
✓ Branch 4 taken 1178 times.
2539 switch(dir)
2325 {
2326 case up:
2327 788 wx=-1;
2328 788 wy=-15;
2329
1/2
✓ Branch 0 taken 788 times.
✗ Branch 1 not taken.
788 if (IsSideSwim())wy+=hammer_swim_up_offset;
2330
2331
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 471 times.
788 if(attackclk>=13)
2332 {
2333 471 wx-=1;
2334 471 wy+=1;
2335 471 ++t;
2336 471 }
2337
2338
2/2
✓ Branch 0 taken 371 times.
✓ Branch 1 taken 417 times.
788 if(attackclk>=15)
2339 {
2340
1/2
✓ Branch 0 taken 417 times.
✗ Branch 1 not taken.
417 if (IsSideSwim())wy-=hammer_swim_up_offset;
2341 417 ++t;
2342 417 }
2343
2344 788 break;
2345
2346 case down:
2347 510 wx=3;
2348 510 wy=-14;
2349
1/2
✓ Branch 0 taken 510 times.
✗ Branch 1 not taken.
510 if (IsSideSwim())wy+=hammer_swim_down_offset;
2350 510 t+=3;
2351
2352
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 306 times.
510 if(attackclk>=13)
2353 {
2354 306 wy+=16;
2355 306 ++t;
2356 306 }
2357
2358
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 272 times.
510 if(attackclk>=15)
2359 {
2360 272 wx-=1;
2361 272 wy+=12;
2362
1/2
✓ Branch 0 taken 272 times.
✗ Branch 1 not taken.
272 if (IsSideSwim())wy-=hammer_swim_down_offset;
2363 272 ++t;
2364 272 }
2365
2366 510 break;
2367
2368 case left:
2369 63 wx=0;
2370 63 wy=-14;
2371
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if (IsSideSwim())wy+=hammer_swim_left_offset;
2372 63 t+=6;
2373 63 f=1;
2374
2375
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 39 times.
63 if(attackclk>=13)
2376 {
2377 39 wx-=7;
2378 39 wy+=8;
2379 39 ++t;
2380 39 }
2381
2382
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 35 times.
63 if(attackclk>=15)
2383 {
2384 35 wx-=8;
2385 35 wy+=8;
2386
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (IsSideSwim())wy-=hammer_swim_left_offset;
2387 35 ++t;
2388 35 }
2389
2390 63 break;
2391
2392 case right:
2393 1178 wx=0;
2394 1178 wy=-14;
2395
1/2
✓ Branch 0 taken 1178 times.
✗ Branch 1 not taken.
1178 if (IsSideSwim())wy+=hammer_swim_right_offset;
2396 1178 t+=6;
2397
2398
2/2
✓ Branch 0 taken 482 times.
✓ Branch 1 taken 696 times.
1178 if(attackclk>=13)
2399 {
2400 696 wx+=7;
2401 696 wy+=8;
2402 696 ++t;
2403 696 }
2404
2405
2/2
✓ Branch 0 taken 558 times.
✓ Branch 1 taken 620 times.
1178 if(attackclk>=15)
2406 {
2407 620 wx+=8;
2408 620 wy+=8;
2409
1/2
✓ Branch 0 taken 620 times.
✗ Branch 1 not taken.
620 if (IsSideSwim())wy-=hammer_swim_right_offset;
2410 620 ++t;
2411 620 }
2412
2413 1178 break;
2414 }
2415
2416
5/8
✓ Branch 0 taken 2539 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1770 times.
✓ Branch 3 taken 769 times.
✓ Branch 4 taken 1770 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1770 times.
✗ Branch 7 not taken.
2539 if(BSZ || ((isdungeon() && currscr<128) && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)))
2417 {
2418 wy+=2;
2419 }
2420
2421 // Stone of Agony
2422
1/2
✓ Branch 0 taken 2539 times.
✗ Branch 1 not taken.
2539 if(agony)
2423 {
2424 wy-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2425 }
2426
2427 2539 w->x = x+wx;
2428 2539 w->y = y+wy-(54-yofs)-fakez;
2429 2539 w->z = (z+zofs);
2430 2539 w->tile = t;
2431 2539 w->flip = f;
2432 2539 w->hxsz=20;
2433 2539 w->hysz=20;
2434
2435
2/2
✓ Branch 0 taken 1241 times.
✓ Branch 1 taken 1298 times.
2539 if(dir>down)
2436 {
2437 1241 w->hysz-=6;
2438 1241 }
2439 else
2440 {
2441 1298 w->hxsz-=6;
2442 1298 w->hyofs=4;
2443 }
2444
2445 2539 w->power = weaponattackpower(itemid);
2446
2447
5/10
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 2455 times.
✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 84 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 84 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
2539 if(attackclk==15 && z==0 && fakez==0 && (sideviewhammerpound() || !isSideViewHero()))
2448 {
2449
2/4
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
84 sfx(((iswaterex(MAPCOMBO(x+wx+8,y+wy), currmap, currscr, -1, x+wx+8, y+wy, true) || COMBOTYPE(x+wx+8,y+wy)==cSHALLOWWATER) && get_bit(quest_rules,qr_MORESOUNDS)) ? WAV_ZN1SPLASH : itemsbuf[itemid].usesound,pan(x.getInt()));
2450 84 }
2451
2452 2539 xofs=oxofs;
2453 2539 yofs=oyofs;
2454 2539 return;
2455 }
2456 93312 }
2457
2/4
✓ Branch 0 taken 3404269 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3404269 times.
3404269 else if(!charging && !spins) // remove the sword
2458 {
2459
2/2
✓ Branch 0 taken 1170425 times.
✓ Branch 1 taken 3404269 times.
4574694 for(int32_t i=0; i<Lwpns.Count(); i++)
2460 {
2461 1170425 weapon *w = (weapon*)Lwpns.spr(i);
2462
2463
4/6
✓ Branch 0 taken 1170425 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1170425 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17120 times.
✓ Branch 5 taken 1153305 times.
1170425 if(w->id == wSword || w->id == wHammer || w->id==wWand)
2464 17120 w->dead=1;
2465 1170425 }
2466 3404269 }
2467
2468
2/2
✓ Branch 0 taken 17663 times.
✓ Branch 1 taken 3479918 times.
3497581 if(invisible)
2469 {
2470 17663 xofs=oxofs;
2471 17663 yofs=oyofs;
2472 17663 return;
2473 }
2474
2475
2/4
✓ Branch 0 taken 3479918 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3479918 times.
3479918 if(action != casting && action != sideswimcasting)
2476 {
2477 // Keep this consistent with checkspecial2, line 7800-ish...
2478
6/6
✓ Branch 0 taken 79541 times.
✓ Branch 1 taken 3400377 times.
✓ Branch 2 taken 74117 times.
✓ Branch 3 taken 5424 times.
✓ Branch 4 taken 5754 times.
✓ Branch 5 taken 68363 times.
3479918 bool inwater = iswaterex(MAPCOMBO(x+4,y+9), currmap, currscr, -1, x+4, y+9, true, false) && iswaterex(MAPCOMBO(x+4,y+15), currmap, currscr, -1, x+4, y+15, true, false) && iswaterex(MAPCOMBO(x+11,y+9), currmap, currscr, -1, x+11, y+9, true, false) && iswaterex(MAPCOMBO(x+11,y+15), currmap, currscr, -1, x+11, y+15, true, false);
2479
2480 3479918 int32_t jumping2 = int32_t(jumping*((zinit.gravity2 / 100)/16.0));
2481 3479918 bool noliftspr = get_bit(quest_rules,qr_NO_LIFT_SPRITE);
2482 //if (jumping!=0) al_trace("%d %d %f %d\n",jumping,zinit.gravity,zinit.gravity/16.0,jumping2);
2483
2/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3237116 times.
✓ Branch 3 taken 242802 times.
3479918 switch(zinit.heroAnimationStyle)
2484 {
2485 case las_original: //normal
2486
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 3237052 times.
3237116 if(action==drowning)
2487 {
2488
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(inwater)
2489 {
2490 64 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2492 64 }
2493 else
2494 {
2495 xofs=oxofs;
2496 yofs=oyofs;
2497 return;
2498 }
2499 64 }
2500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3237052 times.
3237052 else if(action==lavadrowning)
2501 {
2502 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2503 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2504 }
2505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3237052 times.
3237052 else if(action==sidedrowning)
2506 {
2507 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2508 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2509 }
2510
2/4
✓ Branch 0 taken 3237052 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3237052 times.
3237052 else if (action == sideswimming || action == sideswimhit)
2511 {
2512 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2513
2514 if(lstep>=6)
2515 {
2516 if(dir==up)
2517 {
2518 if ( script_hero_sprite <= 0 ) ++flip;
2519 }
2520 else
2521 {
2522 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2523 }
2524 }
2525 }
2526
5/6
✓ Branch 0 taken 3213024 times.
✓ Branch 1 taken 24028 times.
✓ Branch 2 taken 3212844 times.
✓ Branch 3 taken 180 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3212844 times.
3237052 else if(action==swimming || action==swimhit || hopclk==0xFF)
2527 {
2528 24208 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2529
2530
2/2
✓ Branch 0 taken 12228 times.
✓ Branch 1 taken 11980 times.
24208 if(lstep>=6)
2531 {
2532
2/2
✓ Branch 0 taken 1671 times.
✓ Branch 1 taken 10309 times.
11980 if(dir==up)
2533 {
2534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1671 times.
1671 if ( script_hero_sprite <= 0 ) ++flip;
2535 1671 }
2536 else
2537 {
2538
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10309 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10309 times.
10309 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2539 }
2540 11980 }
2541
2542
2/2
✓ Branch 0 taken 22503 times.
✓ Branch 1 taken 1705 times.
24208 if(isDiving())
2543 {
2544 1705 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1705 times.
1705 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2546 1705 }
2547 24208 }
2548
3/4
✓ Branch 0 taken 1618 times.
✓ Branch 1 taken 3211226 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1618 times.
3212844 else if(charging > 0 && attack != wHammer)
2549 {
2550 1618 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2551
2552
2/2
✓ Branch 0 taken 943 times.
✓ Branch 1 taken 675 times.
1618 if(lstep>=6)
2553 {
2554
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 144 times.
675 if(dir==up)
2555 {
2556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if ( script_hero_sprite <= 0 ) ++flip;
2557 144 }
2558 else
2559 {
2560
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 531 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 531 times.
531 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2561 }
2562 675 }
2563 1618 }
2564
9/12
✓ Branch 0 taken 3210984 times.
✓ Branch 1 taken 242 times.
✓ Branch 2 taken 3210984 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11767 times.
✓ Branch 5 taken 3199459 times.
✓ Branch 6 taken 10876 times.
✓ Branch 7 taken 891 times.
✓ Branch 8 taken 10876 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 10876 times.
3211226 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0 && action!=rafting)
2565 {
2566 10876 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10876 times.
10876 if ( script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2568 10876 }
2569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3200350 times.
3200350 else if(fallclk>0)
2570 {
2571 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2572 if ( script_hero_sprite <= 0 ) tile+=((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2573 }
2574
3/6
✓ Branch 0 taken 616 times.
✓ Branch 1 taken 3199734 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 616 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3200350 else if(!noliftspr&&action==lifting&&isLifting())
2575 {
2576 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2577 if(script_hero_sprite <= 0)
2578 {
2579 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2580 auto speed = tliftclk/frames;
2581 if (speed < 1) speed = 1;
2582 auto curframe = (tliftclk - liftclk) / speed;
2583 if (!tliftclk) curframe = frames - 1;
2584 if(unsigned(curframe) < frames)
2585 tile += curframe * (extend == 2 ? 2 : 1);
2586 }
2587 }
2588 else
2589 {
2590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3200350 times.
3200350 if(IsSideSwim())
2591 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2592
3/4
✓ Branch 0 taken 616 times.
✓ Branch 1 taken 3199734 times.
✓ Branch 2 taken 616 times.
✗ Branch 3 not taken.
3200350 else if(!noliftspr&&isLifting())
2593 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2594 3200350 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2595
2596
2/2
✓ Branch 0 taken 2354977 times.
✓ Branch 1 taken 845373 times.
3200350 if(dir>up)
2597 {
2598 2354977 useltm=true;
2599 2354977 shieldModify=true;
2600 2354977 }
2601
2602
2/2
✓ Branch 0 taken 1538493 times.
✓ Branch 1 taken 1661857 times.
3200350 if(lstep>=6)
2603 {
2604
2/2
✓ Branch 0 taken 431116 times.
✓ Branch 1 taken 1230741 times.
1661857 if(dir==up)
2605 {
2606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431116 times.
431116 if ( script_hero_sprite <= 0 ) ++flip;
2607 431116 }
2608 else
2609 {
2610
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1230741 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1230741 times.
1230741 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2611 }
2612 1661857 }
2613 }
2614
2615 3237116 break;
2616
2617 case las_bszelda: //BS
2618
2/2
✓ Branch 0 taken 640 times.
✓ Branch 1 taken 242162 times.
242802 if(action==drowning)
2619 {
2620
1/2
✓ Branch 0 taken 640 times.
✗ Branch 1 not taken.
640 if(inwater)
2621 {
2622 640 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 640 times.
640 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2624 640 }
2625 else
2626 {
2627 xofs=oxofs;
2628 yofs=oyofs;
2629 return;
2630 }
2631 640 }
2632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 242162 times.
242162 else if (action == sidedrowning)
2633 {
2634 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2635 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2636 }
2637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 242162 times.
242162 else if(action==lavadrowning)
2638 {
2639 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2640 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2641 }
2642
2/4
✓ Branch 0 taken 242162 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 242162 times.
242162 else if (action == sideswimming || action == sideswimhit)
2643 {
2644 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2645
2646 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2647 }
2648
4/6
✓ Branch 0 taken 240700 times.
✓ Branch 1 taken 1462 times.
✓ Branch 2 taken 240700 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 240700 times.
242162 else if(action==swimming || action==swimhit || hopclk==0xFF)
2649 {
2650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1462 times.
1462 if (get_bit(quest_rules, qr_COPIED_SWIM_SPRITES))
2651 {
2652 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2653 }
2654 else
2655 {
2656 1462 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2657 }
2658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1462 times.
1462 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2659
2660
2/2
✓ Branch 0 taken 1323 times.
✓ Branch 1 taken 139 times.
1462 if(isDiving())
2661 {
2662
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if (get_bit(quest_rules, qr_COPIED_SWIM_SPRITES))
2663 {
2664 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2665 }
2666 else
2667 {
2668 139 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2669 }
2670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2671 139 }
2672 1462 }
2673
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240700 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240700 else if(charging > 0 && attack != wHammer)
2674 {
2675 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2676 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2677 }
2678
8/10
✓ Branch 0 taken 237585 times.
✓ Branch 1 taken 3115 times.
✓ Branch 2 taken 237585 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2455 times.
✓ Branch 5 taken 238245 times.
✓ Branch 6 taken 1994 times.
✓ Branch 7 taken 461 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1994 times.
240700 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2679 {
2680 1994 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1994 times.
1994 if ( script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2682 1994 }
2683
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 238496 times.
238706 else if(fallclk>0)
2684 {
2685 210 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if ( script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2687 210 }
2688
3/6
✓ Branch 0 taken 14463 times.
✓ Branch 1 taken 224033 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14463 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
238496 else if(!noliftspr&&action==lifting&&isLifting())
2689 {
2690 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2691 if(script_hero_sprite <= 0)
2692 {
2693 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2694 auto speed = tliftclk/frames;
2695 if (speed < 1) speed = 1;
2696 auto curframe = (tliftclk - liftclk) / speed;
2697 if (!tliftclk) curframe = frames - 1;
2698 if(unsigned(curframe) < frames)
2699 tile += curframe * (extend == 2 ? 2 : 1);
2700 }
2701 }
2702 else
2703 {
2704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 238496 times.
238496 if(IsSideSwim())
2705 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2706
3/4
✓ Branch 0 taken 14463 times.
✓ Branch 1 taken 224033 times.
✓ Branch 2 taken 14463 times.
✗ Branch 3 not taken.
238496 else if(!noliftspr&&isLifting())
2707 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2708 238496 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2709
2710
2/2
✓ Branch 0 taken 78107 times.
✓ Branch 1 taken 160389 times.
238496 if(dir>up)
2711 {
2712 160389 useltm=true;
2713 160389 shieldModify=true;
2714 160389 }
2715
2716 /*
2717 else if (dir==up)
2718 {
2719 useltm=true;
2720 }
2721 */
2722
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 235936 times.
238496 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2723 }
2724
2725 242802 break;
2726
2727 case las_zelda3slow: //8-frame Zelda 3 (slow)
2728 case las_zelda3: //8-frame Zelda 3
2729 if(action == drowning)
2730 {
2731 if(inwater)
2732 {
2733 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2734 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2735 }
2736 else
2737 {
2738 xofs=oxofs;
2739 yofs=oyofs;
2740 return;
2741 }
2742 }
2743 else if(action == lavadrowning)
2744 {
2745 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2746 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2747
2748 }
2749 else if(action == sidedrowning)
2750 {
2751 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2752 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2753 }
2754 else if (action == sideswimming || action == sideswimhit)
2755 {
2756 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2757
2758 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2759 }
2760 else if(action == swimming || action==swimhit || hopclk==0xFF)
2761 {
2762 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2763 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2764
2765 if(isDiving())
2766 {
2767 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2768 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2769 }
2770 }
2771 else if(charging > 0 && attack != wHammer)
2772 {
2773 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2774 if (script_hero_sprite <= 0 ) tile+=(extend==2?2:1);
2775 //int32_t l=hero_count/hero_animation_speed;
2776 int32_t l=(hero_count/hero_animation_speed)&15;
2777 //int32_t l=((p[lt_clock]/hero_animation_speed)&15);
2778 l-=((l>3)?1:0)+((l>12)?1:0);
2779 if (script_hero_sprite <= 0 ) tile+=(l/2)*(extend==2?2:1);
2780 }
2781 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2782 {
2783 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2784 if (script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2785 }
2786 else if(fallclk>0)
2787 {
2788 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2789 if (script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2790 }
2791 else if(!noliftspr&&action==lifting&&isLifting())
2792 {
2793 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2794 if(script_hero_sprite <= 0)
2795 {
2796 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2797 auto speed = tliftclk/frames;
2798 if (speed < 1) speed = 1;
2799 auto curframe = (tliftclk-liftclk)/speed;
2800 if (!tliftclk) curframe = frames - 1;
2801 if(unsigned(curframe) < frames)
2802 tile += curframe * (extend == 2 ? 2 : 1);
2803 }
2804 }
2805 else
2806 {
2807 if(IsSideSwim())
2808 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2809 else if(!noliftspr&&isLifting())
2810 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2811 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2812
2813 if(action == walking || action == climbcoverbottom || action == climbcovertop)
2814 {
2815 if (script_hero_sprite <= 0 ) tile += (extend == 2 ? 2 : 1);
2816 }
2817
2818 if(dir>up)
2819 {
2820 useltm=true;
2821 shieldModify=true;
2822 }
2823
2824 if(action == walking || action == hopping || action == climbcoverbottom || action == climbcovertop)
2825 {
2826 //tile+=(extend==2?2:1);
2827 //tile+=(((active_count>>2)%8)*(extend==2?2:1));
2828 int32_t l = hero_count / hero_animation_speed;
2829 l -= ((l > 3) ? 1 : 0) + ((l > 12) ? 1 : 0);
2830 if (script_hero_sprite <= 0 ) tile += (l / 2) * (extend == 2 ? 2 : 1);
2831 }
2832 }
2833
2834 break;
2835
2836 default:
2837 break;
2838 }
2839 3479918 }
2840
2841
6/6
✓ Branch 0 taken 3195187 times.
✓ Branch 1 taken 284731 times.
✓ Branch 2 taken 2262213 times.
✓ Branch 3 taken 932974 times.
✓ Branch 4 taken 120151 times.
✓ Branch 5 taken 2142062 times.
3479918 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2842
2843
2/2
✓ Branch 0 taken 3478450 times.
✓ Branch 1 taken 1468 times.
3479918 if(action==won)
2844 {
2845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1468 times.
1468 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - 2;
2846 1468 }
2847
2848
4/4
✓ Branch 0 taken 3452938 times.
✓ Branch 1 taken 26980 times.
✓ Branch 2 taken 29758 times.
✓ Branch 3 taken 3423180 times.
3479918 if(action==landhold1 || action==landhold2)
2849 {
2850 56738 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2851
6/6
✓ Branch 0 taken 52500 times.
✓ Branch 1 taken 4238 times.
✓ Branch 2 taken 38865 times.
✓ Branch 3 taken 13635 times.
✓ Branch 4 taken 12007 times.
✓ Branch 5 taken 26858 times.
56738 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2852 56738 herotile(&tile, &flip, &extend, (action==landhold1)?ls_landhold1:ls_landhold2, dir, zinit.heroAnimationStyle);
2853 56738 }
2854
4/4
✓ Branch 0 taken 3422790 times.
✓ Branch 1 taken 390 times.
✓ Branch 2 taken 130 times.
✓ Branch 3 taken 3422660 times.
3423180 else if(action==waterhold1 || action==waterhold2)
2855 {
2856 520 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2857 520 herotile(&tile, &flip, &extend, (action==waterhold1)?ls_waterhold1:ls_waterhold2, dir, zinit.heroAnimationStyle);
2858 520 }
2859
2/4
✓ Branch 0 taken 3422660 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3422660 times.
3422660 else if(action==sidewaterhold1 || action==sidewaterhold2)
2860 {
2861 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2862 herotile(&tile, &flip, &extend, (action==sidewaterhold1)?ls_sidewaterhold1:ls_sidewaterhold2, dir, zinit.heroAnimationStyle);
2863 }
2864
2865
2/4
✓ Branch 0 taken 3479918 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3479918 times.
3479918 if(action!=casting && action!=sideswimcasting)
2866 {
2867
2/2
✓ Branch 0 taken 893469 times.
✓ Branch 1 taken 2586449 times.
3479918 if(useltm)
2868 {
2869
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 2583889 times.
2586449 if (script_hero_sprite <= 0 ) tile+=getTileModifier();
2870 2586449 }
2871 3479918 }
2872
2873 // Stone of Agony
2874
2/2
✓ Branch 0 taken 3479886 times.
✓ Branch 1 taken 32 times.
3479918 if(agony)
2875 {
2876
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2877 32 }
2878
2879
6/6
✓ Branch 0 taken 1163356 times.
✓ Branch 1 taken 2316562 times.
✓ Branch 2 taken 1108839 times.
✓ Branch 3 taken 54517 times.
✓ Branch 4 taken 59060 times.
✓ Branch 5 taken 1104296 times.
3479918 if(!(get_bit(quest_rules,qr_HEROFLICKER)&&((superman||hclk)&&(frame&1))))
2880 {
2881 3420858 masked_draw(dest);
2882 3420858 }
2883
2884 //draw held items after Hero so they don't go behind his head
2885
4/4
✓ Branch 0 taken 3452938 times.
✓ Branch 1 taken 26980 times.
✓ Branch 2 taken 29758 times.
✓ Branch 3 taken 3423180 times.
3479918 if(action==landhold1 || action==landhold2)
2886 {
2887
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 56730 times.
56738 if(holditem > -1)
2888 {
2889
2/2
✓ Branch 0 taken 24171 times.
✓ Branch 1 taken 32559 times.
56730 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2890 {
2891 24171 putitem2(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2892 24171 }
2893 else
2894 {
2895 32559 putitem(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2896 }
2897 56730 }
2898 56738 }
2899
4/4
✓ Branch 0 taken 3422790 times.
✓ Branch 1 taken 390 times.
✓ Branch 2 taken 130 times.
✓ Branch 3 taken 3422660 times.
3423180 else if(action==waterhold1 || action==waterhold2)
2900 {
2901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 520 times.
520 if(holditem > -1)
2902 {
2903
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 260 times.
520 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2904 {
2905 260 putitem2(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2906 260 }
2907 else
2908 {
2909 260 putitem(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2910 }
2911 520 }
2912 520 }
2913
2/4
✓ Branch 0 taken 3422660 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3422660 times.
3422660 else if(action==sidewaterhold1 || action==sidewaterhold2) //!DIMITODO: Check to see if this looks right or if it needs waterhold's offset.
2914 {
2915 if(holditem > -1)
2916 {
2917 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2918 {
2919 putitem2(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2920 }
2921 else
2922 {
2923 putitem(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2924 }
2925 }
2926 }
2927
3/4
✓ Branch 0 taken 11551 times.
✓ Branch 1 taken 3468367 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11551 times.
3479918 if(fairyclk==0||(get_bit(quest_rules,qr_NOHEARTRING)))
2928 {
2929 3468367 xofs=oxofs;
2930 3468367 yofs=oyofs;
2931 3468367 return;
2932 }
2933
2934 11551 double a2 = fairyclk*int64_t(2)*PI/80 + (PI/2);
2935 11551 int32_t hearts=0;
2936 // int32_t htile = QHeader.dat_flags[ZQ_TILES] ? 2 : 0;
2937 11551 int32_t htile = 2;
2938
2939 11551 do
2940 {
2941 72528 int32_t nx=125;
2942
2943
2/2
✓ Branch 0 taken 51168 times.
✓ Branch 1 taken 21360 times.
72528 if(get_bit(quest_rules,qr_HEARTRINGFIX))
2944 {
2945 21360 nx=x;
2946 21360 }
2947
2948 72528 int32_t ny=88;
2949
2950
2/2
✓ Branch 0 taken 51168 times.
✓ Branch 1 taken 21360 times.
72528 if(get_bit(quest_rules,qr_HEARTRINGFIX))
2951 {
2952 21360 ny=y;
2953 21360 }
2954
2955 72528 double tx = zc::math::Cos(a2)*53 +nx;
2956 72528 double ty = -zc::math::Sin(a2)*53 +ny+playing_field_offset;
2957 72528 overtile8(dest,htile,int32_t(tx),int32_t(ty),1,0);
2958 72528 a2-=PI/4;
2959 72528 ++hearts;
2960
2/2
✓ Branch 0 taken 60977 times.
✓ Branch 1 taken 11551 times.
145056 }
2961
2/2
✓ Branch 0 taken 5680 times.
✓ Branch 1 taken 66848 times.
72528 while(a2>PI/2 && hearts<8);
2962
2963 11551 xofs=oxofs;
2964 11551 yofs=oyofs;
2965 3918333 }
2966
2967 3829346 void HeroClass::masked_draw(BITMAP* dest)
2968 {
2969
12/12
✓ Branch 0 taken 2525270 times.
✓ Branch 1 taken 1304076 times.
✓ Branch 2 taken 2396295 times.
✓ Branch 3 taken 128975 times.
✓ Branch 4 taken 2361840 times.
✓ Branch 5 taken 34455 times.
✓ Branch 6 taken 2324877 times.
✓ Branch 7 taken 36963 times.
✓ Branch 8 taken 2272875 times.
✓ Branch 9 taken 52002 times.
✓ Branch 10 taken 2334178 times.
✓ Branch 11 taken 62117 times.
3829346 if(isdungeon() && currscr<128 && (x<16 || x>224 || y<18 || y>146) && !get_bit(quest_rules,qr_FREEFORM))
2970 {
2971 // clip under doorways
2972 62117 BITMAP *sub=create_sub_bitmap(dest,16,playing_field_offset+16,224,144);
2973
2974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62117 times.
62117 if(sub!=NULL)
2975 {
2976 62117 yofs -= (playing_field_offset+16);
2977 62117 xofs -= 16;
2978 62117 sprite::draw(sub);
2979
1/2
✓ Branch 0 taken 62117 times.
✗ Branch 1 not taken.
62117 if(lift_wpn)
2980 {
2981 handle_lift(false);
2982 bool shad = lift_wpn->has_shadow;
2983 lift_wpn->has_shadow = false;
2984 lift_wpn->draw(sub);
2985 lift_wpn->has_shadow = shad;
2986 }
2987 62117 prompt_draw(sub);
2988 62117 xofs+=16;
2989 62117 yofs += (playing_field_offset+16);
2990 62117 destroy_bitmap(sub);
2991 62117 }
2992 62117 }
2993 else
2994 {
2995 3767229 sprite::draw(dest);
2996
1/2
✓ Branch 0 taken 3767229 times.
✗ Branch 1 not taken.
3767229 if(lift_wpn)
2997 {
2998 handle_lift(false);
2999 bool shad = lift_wpn->has_shadow;
3000 lift_wpn->has_shadow = false;
3001 lift_wpn->draw(dest);
3002 lift_wpn->has_shadow = shad;
3003 }
3004 3767229 prompt_draw(dest);
3005 }
3006
3007 3829346 return;
3008 }
3009 3829346 void HeroClass::prompt_draw(BITMAP* dest)
3010 {
3011
2/2
✓ Branch 0 taken 3827850 times.
✓ Branch 1 taken 1496 times.
3829346 if(!prompt_combo) return;
3012 1496 int32_t sx = real_x(x+xofs+prompt_x);
3013 1496 int32_t sy = real_y(y + yofs + prompt_y) - real_z(z + zofs);
3014 1496 sy -= fake_z(fakez);
3015 1496 overcombo(dest, sx, sy, prompt_combo, prompt_cset);
3016 1496 return;
3017 3829346 }
3018
3019 5744 void collectitem_script(int32_t id)
3020 {
3021
2/2
✓ Branch 0 taken 5666 times.
✓ Branch 1 taken 78 times.
5744 if(itemsbuf[id].collect_script)
3022 {
3023 //clear item script stack.
3024 //ri = &(itemScriptData[id]);
3025 //ri->Clear();
3026 //itemCollectScriptData[id].Clear();
3027 //for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id][q] = 0;
3028 78 ri = &(itemCollectScriptData[id]);
3029
2/2
✓ Branch 0 taken 79872 times.
✓ Branch 1 taken 78 times.
79950 for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id][q] = 0xFFFF;
3030 78 ri->Clear();
3031 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, ((id & 0xFFF)*-1));
3032
3033
2/6
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 78 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
78 if ( id > 0 && !(item_collect_doscript[id] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) ) //No collect script on item 0.
3034 {
3035 78 item_collect_doscript[id] = 1;
3036 78 itemscriptInitialised[id] = 0;
3037 78 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, ((id)*-1));
3038 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
3039 78 FFCore.deallocateAllArrays(SCRIPT_ITEM,-(id));
3040 78 }
3041 else if (id == 0 && !(item_collect_doscript[id] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING))) //item 0
3042 {
3043 item_collect_doscript[id] = 1;
3044 itemscriptInitialised[id] = 0;
3045 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, COLLECT_SCRIPT_ITEM_ZERO);
3046 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
3047 FFCore.deallocateAllArrays(SCRIPT_ITEM,COLLECT_SCRIPT_ITEM_ZERO);
3048 }
3049 //runningItemScripts[id] = 0;
3050 78 }
3051 5744 }
3052 504 void passiveitem_script(int32_t id, bool doRun = false)
3053 {
3054 //Passive item scripts on colelction
3055
3/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 488 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
504 if(itemsbuf[id].script && ( (itemsbuf[id].flags&ITEM_PASSIVESCRIPT) && (get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING)) ))
3056 {
3057 ri = &(itemScriptData[id]);
3058 for ( int32_t q = 0; q < 1024; q++ ) item_stack[id][q] = 0xFFFF;
3059 ri->Clear();
3060 item_doscript[id] = 1;
3061 itemscriptInitialised[id] = 0;
3062
3063
3064 if(get_bit(quest_rules,qr_PASSIVE_ITEM_SCRIPT_ONLY_HIGHEST)
3065 && current_item(itemsbuf[id].family) > itemsbuf[id].fam_type)
3066 {
3067 item_doscript[id] = 0;
3068 return;
3069 }
3070 if(doRun)
3071 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].script, id);
3072 }
3073 504 }
3074
3075 // separate case for sword/wand/hammer/slashed weapons only
3076 // the main weapon checking is in the global function check_collisions()
3077 3394919 bool HeroClass::checkstab()
3078 {
3079
13/14
✓ Branch 0 taken 2887499 times.
✓ Branch 1 taken 507420 times.
✓ Branch 2 taken 120233 times.
✓ Branch 3 taken 387187 times.
✓ Branch 4 taken 103625 times.
✓ Branch 5 taken 16608 times.
✓ Branch 6 taken 101086 times.
✓ Branch 7 taken 2539 times.
✓ Branch 8 taken 101086 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 90603 times.
✓ Branch 11 taken 10483 times.
✓ Branch 12 taken 121408 times.
✓ Branch 13 taken 295409 times.
3394919 if(action!=attacking && action!=sideswimattacking || (attack!=wSword && attack!=wWand && attack!=wHammer && attack!=wCByrna && attack!=wFire && attack != wBugNet)
3080 507420 || (attackclk<=4))
3081 3099510 return false;
3082
3083 295409 weapon *w=NULL;
3084
3085 295409 int32_t wx=0,wy=0,wz=0,wxsz=0,wysz=0;
3086 295409 bool found = false;
3087 295409 int32_t melee_weapon_index = 0;
3088 295409 int32_t parentitem=-1;
3089 295409 weapon* meleeweap = nullptr;
3090
2/2
✓ Branch 0 taken 33670 times.
✓ Branch 1 taken 347999 times.
381669 for(int32_t i=0; i<Lwpns.Count(); i++)
3091 {
3092 347999 w = (weapon*)Lwpns.spr(i);
3093
3094
5/6
✓ Branch 0 taken 347999 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9719 times.
✓ Branch 3 taken 338280 times.
✓ Branch 4 taken 86260 times.
✓ Branch 5 taken 261739 times.
347999 if(w->id == (attack==wCByrna || attack==wFire ? wWand : attack)) // Kludge: Byrna and Candle sticks are wWand-type.
3095 {
3096 261739 found = true;
3097 261739 melee_weapon_index = i+1;
3098 261739 meleeweap = w;
3099 // Position the sword as Hero slashes with it.
3100
3/4
✓ Branch 0 taken 259540 times.
✓ Branch 1 taken 2199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 259540 times.
261739 if(w->id!=wHammer&&w->id!=wBugNet)
3101 259540 positionSword(w,w->parentitem);
3102
3103 261739 wx=w->x;
3104 261739 wy=w->y;
3105 261739 wz=w->z;
3106 261739 wxsz = w->hxsz;
3107 261739 wysz = w->hysz;
3108 261739 parentitem = w->parentitem;
3109 261739 break;
3110 }
3111 86260 }
3112
3113
6/6
✓ Branch 0 taken 274198 times.
✓ Branch 1 taken 21211 times.
✓ Branch 2 taken 28717 times.
✓ Branch 3 taken 245481 times.
✓ Branch 4 taken 1806 times.
✓ Branch 5 taken 26911 times.
295409 if(attack==wSword && attackclk>=14 && charging==0)
3114 26911 return false;
3115
3116
2/2
✓ Branch 0 taken 234828 times.
✓ Branch 1 taken 33670 times.
268498 if(!found)
3117 33670 return false;
3118
3119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 234828 times.
234828 if(attack == wFire)
3120 return false;
3121
3122
2/2
✓ Branch 0 taken 232629 times.
✓ Branch 1 taken 2199 times.
234828 if(attack==wHammer)
3123 {
3124
2/2
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 1344 times.
2199 if(attackclk<15)
3125 {
3126
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 260 times.
✓ Branch 2 taken 170 times.
✓ Branch 3 taken 20 times.
✓ Branch 4 taken 405 times.
855 switch(w->dir)
3127 {
3128 case up:
3129 260 wx=x-1;
3130 260 wy=y-4;
3131 260 break;
3132
3133 case down:
3134 170 wx=x+8;
3135 170 wy=y+28;
3136 170 break; // This is consistent with 2.10
3137
3138 case left:
3139 20 wx=x-13;
3140 20 wy=y+14;
3141 20 break;
3142
3143 case right:
3144 405 wx=x+21;
3145 405 wy=y+14;
3146 405 break;
3147 }
3148
3149
5/8
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 771 times.
✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 84 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 84 times.
855 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
3150 {
3151 //decorations.add(new dHammerSmack((zfix)wx, (zfix)wy, dHAMMERSMACK, 0));
3152 /* The hammer smack sprites weren't being positioned properly if Hero changed directions on the same frame that they are created.
3153 switch(dir)
3154 {
3155 case up:
3156 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
3157 break;
3158
3159 case down:
3160 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
3161 break;
3162
3163 case left:
3164 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
3165 break;
3166
3167 case right:
3168 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
3169 break;
3170 }
3171 */
3172 84 }
3173
3174 855 return false;
3175 }
3176
2/2
✓ Branch 0 taken 1260 times.
✓ Branch 1 taken 84 times.
1344 else if(attackclk==15)
3177 {
3178 // Hammer's reach needs adjusted slightly for backward compatibility
3179
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 26 times.
84 if(w->dir==up)
3180 26 w->hyofs-=1;
3181
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 2 times.
58 else if(w->dir==left)
3182 2 w->hxofs-=2;
3183 84 }
3184 1344 }
3185
3186 // The return of Spaghetti Code Constants!
3187
5/6
✓ Branch 0 taken 10628 times.
✓ Branch 1 taken 223345 times.
✓ Branch 2 taken 222001 times.
✓ Branch 3 taken 1344 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1344 times.
233973 int32_t itype = (attack==wWand ? itype_wand : attack==wSword ? itype_sword : attack==wCByrna ? itype_cbyrna : attack==wBugNet ? itype_bugnet : itype_hammer);
3188
3/4
✓ Branch 0 taken 6320 times.
✓ Branch 1 taken 227653 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6320 times.
233973 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
3189 233973 itemid = vbound(itemid, 0, MAXITEMS-1);
3190
3191 // The sword offsets aren't based on anything other than what felt about right
3192 // compared to the NES game and what mostly kept it from hitting things that
3193 // should clearly be out of range. They could probably still use more tweaking.
3194 // Don't use 2.10 for reference; it's pretty far off.
3195 // - Saf
3196
3197
6/6
✓ Branch 0 taken 23136 times.
✓ Branch 1 taken 210837 times.
✓ Branch 2 taken 5295 times.
✓ Branch 3 taken 17841 times.
✓ Branch 4 taken 5295 times.
✓ Branch 5 taken 17841 times.
233973 if(game->get_canslash() && (attack==wSword || attack==wWand) && itemsbuf[itemid].flags & ITEM_FLAG4)
3198 {
3199
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3342 times.
✓ Branch 2 taken 5090 times.
✓ Branch 3 taken 5178 times.
✓ Branch 4 taken 4231 times.
17841 switch(w->dir)
3200 {
3201 case up:
3202
2/2
✓ Branch 0 taken 2152 times.
✓ Branch 1 taken 1190 times.
3342 if(attackclk<8)
3203 {
3204 1190 wy-=4;
3205 1190 }
3206
3207 3342 break;
3208
3209 case down:
3210 //if(attackclk<8)
3211 {
3212 5090 wy-=2;
3213 }
3214 5090 break;
3215
3216 case left:
3217
3218 //if(attackclk<8)
3219 {
3220 5178 wx+=2;
3221 }
3222
3223 5178 break;
3224
3225 case right:
3226
3227 //if(attackclk<8)
3228 {
3229 4231 wx-=3;
3230 //wy+=((spins>0 || get_bit(quest_rules, qr_SLASHFLIPFIX)) ? -4 : 4);
3231 }
3232
3233 4231 break;
3234 }
3235 17841 }
3236
3237
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 51088 times.
✓ Branch 2 taken 51595 times.
✓ Branch 3 taken 66184 times.
✓ Branch 4 taken 65106 times.
233973 switch(w->dir)
3238 {
3239 case up:
3240 51088 wx+=2;
3241 51088 break;
3242
3243 case down:
3244 51595 break;
3245
3246 case left:
3247 66184 wy-=3;
3248 66184 break;
3249
3250 case right:
3251 65106 wy-=3;
3252 65106 break;
3253 }
3254
3255 233973 wx+=w->hxofs;
3256 233973 wy+=w->hyofs;
3257 233973 wy-=(w->fakez).getInt();
3258
3259
2/2
✓ Branch 0 taken 231495 times.
✓ Branch 1 taken 1271345 times.
1502840 for(int32_t i=0; i<guys.Count(); i++)
3260 {
3261
1/2
✓ Branch 0 taken 1271345 times.
✗ Branch 1 not taken.
1271345 if(attack==wBugNet) break;
3262 // So that Hero can actually hit peahats while jumping, his weapons' hzsz becomes 16 in midair.
3263
6/6
✓ Branch 0 taken 24047 times.
✓ Branch 1 taken 1247298 times.
✓ Branch 2 taken 23636 times.
✓ Branch 3 taken 411 times.
✓ Branch 4 taken 23553 times.
✓ Branch 5 taken 83 times.
1271371 if((guys.spr(i)->hit(wx,wy,wz,wxsz,wysz,wz>0?16:8) && ((attack!=wWand && attack!=wHammer && attack!=wCByrna) || !(itemsbuf[itemid].flags & ITEM_FLAG3)))
3264
5/6
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 208 times.
✓ Branch 2 taken 1163303 times.
✓ Branch 3 taken 84281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1247584 times.
1247792 || ((attack==wWand || attack==wCByrna) && guys.spr(i)->hit(wx,wy-8,z,16,24,z>8) && !(itemsbuf[itemid].flags & ITEM_FLAG3))
3265
4/4
✓ Branch 0 taken 4842 times.
✓ Branch 1 taken 1242742 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 4816 times.
1247584 || (attack==wHammer && guys.spr(i)->hit(wx,wy-8,z,16,24,z>0?16:8) && !(itemsbuf[itemid].flags & ITEM_FLAG3)))
3266 {
3267 // Checking the whimsical ring for every collision check causes
3268 // an odd bug. It's much more likely to activate on a 0-damage
3269 // weapon, since a 0-damage hit won't make the enemy invulnerable
3270 // to damaging hits in the following frames.
3271
3272 23761 int32_t whimsyid = current_item_id(itype_whimsicalring);
3273
3274 23761 int32_t dmg = weaponattackpower(itemid);
3275
2/2
✓ Branch 0 taken 21860 times.
✓ Branch 1 taken 1901 times.
23761 if(whimsyid>-1)
3276 {
3277
3/4
✓ Branch 0 taken 1901 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115 times.
✓ Branch 3 taken 1786 times.
1901 if(!(zc_oldrand()%zc_max(itemsbuf[whimsyid].misc1,1)))
3278 115 dmg += current_item_power(itype_whimsicalring);
3279 1786 else whimsyid = -1;
3280 1901 }
3281 23761 int32_t atkringid = current_item_id(itype_atkring);
3282
1/2
✓ Branch 0 taken 23761 times.
✗ Branch 1 not taken.
23761 if(atkringid>-1)
3283 {
3284 dmg *= itemsbuf[atkringid].misc2; //Multiplier
3285 dmg += itemsbuf[atkringid].misc1; //Additive
3286 }
3287
3288 23761 int32_t h = hit_enemy(i,attack,dmg*game->get_hero_dmgmult(),wx,wy,dir,directWpn);
3289 23761 enemy *e = (enemy*)guys.spr(i);
3290
2/2
✓ Branch 0 taken 8621 times.
✓ Branch 1 taken 15140 times.
23761 if (h == -1) { e->hitby[HIT_BY_LWEAPON] = melee_weapon_index; } //temp_hit = true; }
3291 //melee weapons and non-melee weapons both writing to this index may be a problem. It needs to be cleared by something earlier than this check.
3292
3293
4/4
✓ Branch 0 taken 15140 times.
✓ Branch 1 taken 8621 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 15095 times.
23761 if(h<0 && whimsyid>-1)
3294 {
3295 45 sfx(itemsbuf[whimsyid].usesound);
3296 45 }
3297
3298
4/4
✓ Branch 0 taken 20548 times.
✓ Branch 1 taken 3213 times.
✓ Branch 2 taken 20454 times.
✓ Branch 3 taken 94 times.
23761 if(h && charging>0)
3299 {
3300 94 attackclk = SWORDTAPFRAME;
3301 94 spins=0;
3302 94 }
3303
3304
6/8
✓ Branch 0 taken 20548 times.
✓ Branch 1 taken 3213 times.
✓ Branch 2 taken 17451 times.
✓ Branch 3 taken 3097 times.
✓ Branch 4 taken 17451 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 17451 times.
23761 if(h && hclk==0 && inlikelike != 1 && !get_bit(quest_rules, qr_DYING_ENEMIES_IGNORE_STUN))
3305 {
3306
2/2
✓ Branch 0 taken 17392 times.
✓ Branch 1 taken 59 times.
17451 if(GuyHit(i,x+7,y+7-fakez,z,2,2,hzsz)!=-1)
3307 {
3308 59 hithero(i);
3309 59 }
3310 17451 }
3311
3312
2/2
✓ Branch 0 taken 21283 times.
✓ Branch 1 taken 2478 times.
23761 if(h==2)
3313 2478 break;
3314 21283 }
3315 1268867 }
3316
3317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233973 times.
467946 if(attack == wBugNet
3318
2/4
✓ Branch 0 taken 233973 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 233973 times.
233973 || (parentitem==-1&&!get_bit(quest_rules,qr_NOITEMMELEE))
3319
1/2
✓ Branch 0 taken 233973 times.
✗ Branch 1 not taken.
233973 || (parentitem>-1&&!(itemsbuf[parentitem].flags & ITEM_FLAG7)))
3320 {
3321
1/4
✓ Branch 0 taken 233973 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
233973 int32_t bugnetid = attack != wBugNet ? -1 : (parentitem > -1 ? parentitem : current_item_id(itype_bugnet));
3322
2/2
✓ Branch 0 taken 233973 times.
✓ Branch 1 taken 60418 times.
294391 for(int32_t j=0; j<items.Count(); j++)
3323 {
3324 60418 item* ptr = (item*)items.spr(j);
3325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60418 times.
60418 bool dofairy = (attack==wBugNet && itemsbuf[ptr->id].family == itype_fairy)
3326 && (bugnetid > -1 && !(itemsbuf[bugnetid].flags & ITEM_FLAG1));
3327
3328
2/4
✓ Branch 0 taken 60418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60418 times.
✗ Branch 3 not taken.
60418 if((itemsbuf[ptr->id].family == itype_bottlefill || dofairy) && !game->canFillBottle())
3329 continue; //No picking these up unless you have a bottle to fill!
3330
4/6
✓ Branch 0 taken 60418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9097 times.
✓ Branch 3 taken 51321 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9097 times.
60418 if((ptr->pickup & ipCANGRAB) || (ptr->pickup & ipTIMER) || dofairy)
3331 {
3332
6/8
✓ Branch 0 taken 51321 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18970 times.
✓ Branch 3 taken 32351 times.
✓ Branch 4 taken 32351 times.
✓ Branch 5 taken 18970 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 32351 times.
51321 if(((ptr->pickup & ipCANGRAB) || ptr->clk2 >= 32 || dofairy) && !ptr->fallclk && !ptr->drownclk)
3333 {
3334
6/6
✓ Branch 0 taken 30798 times.
✓ Branch 1 taken 1553 times.
✓ Branch 2 taken 841 times.
✓ Branch 3 taken 29957 times.
✓ Branch 4 taken 30798 times.
✓ Branch 5 taken 1553 times.
63149 if(ptr->hit(wx,wy,z,wxsz,wysz,1) || (attack==wWand && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1))
3335
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 841 times.
✓ Branch 2 taken 30702 times.
✓ Branch 3 taken 96 times.
30798 || (attack==wHammer && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1)))
3336 {
3337 1553 int32_t pickup = ptr->pickup;
3338 1553 int32_t id2 = ptr->id;
3339 1553 int32_t pstr = ptr->pstring;
3340 1553 int32_t pstr_flags = ptr->pickup_string_flags;
3341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1553 times.
1553 if(!dofairy)
3342 {
3343 1553 std::vector<int32_t> &ev = FFCore.eventData;
3344 1553 ev.clear();
3345 1553 ev.push_back(id2*10000);
3346 1553 ev.push_back(pickup*10000);
3347 1553 ev.push_back(pstr*10000);
3348 1553 ev.push_back(pstr_flags*10000);
3349 1553 ev.push_back(0);
3350 1553 ev.push_back(ptr->getUID());
3351 1553 ev.push_back(GENEVT_ICTYPE_MELEE*10000);
3352 1553 ev.push_back(w->getUID());
3353
3354 1553 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
3355 1553 bool nullify = ev[4] != 0;
3356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1553 times.
1553 if(nullify) continue;
3357 1553 id2 = ev[0]/10000;
3358 1553 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
3359 1553 pstr = ev[2] / 10000;
3360 1553 pstr_flags = ev[3] / 10000;
3361 1553 }
3362
3363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1553 times.
1553 if(pickup&ipONETIME) // set mITEM for one-time-only items
3364 setmapflag(mITEM);
3365
1/2
✓ Branch 0 taken 1553 times.
✗ Branch 1 not taken.
1553 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
3366 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
3367
3368
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1553 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1553 if(ptr->pickupexstate > -1 && ptr->pickupexstate < 32)
3369 setxmapflag(1<<ptr->pickupexstate);
3370
1/2
✓ Branch 0 taken 1553 times.
✗ Branch 1 not taken.
1553 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
3371 {
3372 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
3373 hidden_entrance(0, true, false, -5);
3374 }
3375 //!DIMI
3376
3377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1553 times.
1553 if(dofairy)
3378 {
3379 game->fillBottle(itemsbuf[ptr->id].misc4);
3380 }
3381 else
3382 {
3383 1553 collectitem_script(id2);
3384
3385 1553 getitem(id2, false, true);
3386 }
3387 1553 items.del(j);
3388
3389
2/2
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 1553 times.
3526 for(int32_t i=0; i<Lwpns.Count(); i++)
3390 {
3391 1973 weapon *w2 = (weapon*)Lwpns.spr(i);
3392
3393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973 times.
1973 if(w2->dragging==j)
3394 {
3395 w2->dragging=-1;
3396 }
3397
1/2
✓ Branch 0 taken 1973 times.
✗ Branch 1 not taken.
1973 else if(w2->dragging>j)
3398 {
3399 w2->dragging-=1;
3400 }
3401 1973 }
3402
3403
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1553 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1553 if ( (pstr > 0 && pstr < msg_count) )
3404 {
3405 if ( ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
3406 {
3407 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) )
3408 FFCore.SetItemMessagePlayed(id2);
3409 donewmsg(pstr);
3410 break;
3411 }
3412 }
3413
3414 1553 --j;
3415 1553 }
3416 32351 }
3417 51321 }
3418 60418 }
3419 233973 }
3420
3421
2/4
✓ Branch 0 taken 233973 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 233973 times.
233973 if(attack==wCByrna || attack==wBugNet)
3422 return false;
3423
3424
2/2
✓ Branch 0 taken 222001 times.
✓ Branch 1 taken 11972 times.
233973 if(attack==wSword)
3425 {
3426
2/2
✓ Branch 0 taken 194338 times.
✓ Branch 1 taken 27663 times.
222001 if(attackclk == 6)
3427 {
3428
2/2
✓ Branch 0 taken 4868688 times.
✓ Branch 1 taken 27663 times.
4896351 for(int32_t q=0; q<176; q++)
3429 {
3430 4868688 set_bit(screengrid,q,0);
3431 4868688 set_bit(screengrid_layer[0],q,0);
3432 4868688 set_bit(screengrid_layer[1],q,0);
3433
3434 4868688 }
3435
3436
2/2
✓ Branch 0 taken 442608 times.
✓ Branch 1 taken 27663 times.
470271 for(dword q = MAXFFCS/8; q > 0; --q)
3437 442608 ffcgrid[q-1] = 0;
3438 27663 }
3439
3440
4/4
✓ Branch 0 taken 49040 times.
✓ Branch 1 taken 172961 times.
✓ Branch 2 taken 24788 times.
✓ Branch 3 taken 24252 times.
222001 if(dir==up && ((x.getInt()&15)==0))
3441 {
3442 24252 check_slash_block(wx,wy);
3443 24252 check_slash_block(wx,wy+8);
3444
3445 //layers
3446 24252 check_slash_block_layer(wx,wy,1);
3447 24252 check_slash_block_layer(wx,wy+8,1);
3448 24252 check_slash_block_layer(wx,wy,1);
3449 24252 check_slash_block_layer(wx,wy+8,1);
3450 //2
3451 24252 check_slash_block_layer(wx,wy,2);
3452 24252 check_slash_block_layer(wx,wy+8,2);
3453 24252 check_slash_block_layer(wx,wy,2);
3454 24252 check_slash_block_layer(wx,wy+8,2);
3455
3456
3457
3458 24252 }
3459
7/8
✓ Branch 0 taken 24788 times.
✓ Branch 1 taken 172961 times.
✓ Branch 2 taken 968 times.
✓ Branch 3 taken 23820 times.
✓ Branch 4 taken 122 times.
✓ Branch 5 taken 846 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 122 times.
197749 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3460 {
3461 24666 check_slash_block(wx,wy);
3462 24666 check_slash_block(wx,wy+8);
3463 24666 check_slash_block(wx+8,wy);
3464 24666 check_slash_block(wx+8,wy+8);
3465 ///layer 1
3466 24666 check_slash_block_layer(wx,wy,1);
3467 24666 check_slash_block_layer(wx,wy+8,1);
3468 24666 check_slash_block_layer(wx+8,wy,1);
3469 24666 check_slash_block_layer(wx+8,wy+8,1);
3470 ///layer 2
3471 24666 check_slash_block_layer(wx,wy,2);
3472 24666 check_slash_block_layer(wx,wy+8,2);
3473 24666 check_slash_block_layer(wx+8,wy,2);
3474 24666 check_slash_block_layer(wx+8,wy+8,2);
3475 24666 }
3476
3477
4/4
✓ Branch 0 taken 49928 times.
✓ Branch 1 taken 172073 times.
✓ Branch 2 taken 25987 times.
✓ Branch 3 taken 23941 times.
222001 if(dir==down && ((x.getInt()&15)==0))
3478 {
3479 25987 check_slash_block(wx,wy+wysz-8);
3480 25987 check_slash_block(wx,wy+wysz);
3481
3482 //layer 1
3483 25987 check_slash_block_layer(wx,wy+wysz-8,1);
3484 25987 check_slash_block_layer(wx,wy+wysz,1);
3485 //layer 2
3486 25987 check_slash_block_layer(wx,wy+wysz-8,2);
3487 25987 check_slash_block_layer(wx,wy+wysz,2);
3488 25987 }
3489
7/8
✓ Branch 0 taken 23941 times.
✓ Branch 1 taken 172073 times.
✓ Branch 2 taken 1871 times.
✓ Branch 3 taken 22070 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 1815 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 56 times.
196014 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3490 {
3491 23885 check_slash_block(wx,wy+wysz-8);
3492 23885 check_slash_block(wx,wy+wysz);
3493 23885 check_slash_block(wx+8,wy+wysz-8);
3494 23885 check_slash_block(wx+8,wy+wysz);
3495 //layer 1
3496 23885 check_slash_block_layer(wx,wy+wysz-8,1);
3497 23885 check_slash_block_layer(wx,wy+wysz,1);
3498 23885 check_slash_block_layer(wx+8,wy+wysz-8,1);
3499 23885 check_slash_block_layer(wx+8,wy+wysz,1);
3500 //layer 2
3501 23885 check_slash_block_layer(wx,wy+wysz-8,2);
3502 23885 check_slash_block_layer(wx,wy+wysz,2);
3503 23885 check_slash_block_layer(wx+8,wy+wysz-8,2);
3504 23885 check_slash_block_layer(wx+8,wy+wysz,2);
3505 23885 }
3506
3507
2/2
✓ Branch 0 taken 160358 times.
✓ Branch 1 taken 61643 times.
222001 if(dir==left)
3508 {
3509 61643 check_slash_block(wx,wy+8);
3510 61643 check_slash_block(wx+8,wy+8);
3511 //layer 1
3512 61643 check_slash_block_layer(wx,wy+8,1);
3513 61643 check_slash_block_layer(wx+8,wy+8,1);
3514 //layer 2
3515 61643 check_slash_block_layer(wx,wy+8,2);
3516 61643 check_slash_block_layer(wx+8,wy+8,2);
3517 61643 }
3518
3519
2/2
✓ Branch 0 taken 160611 times.
✓ Branch 1 taken 61390 times.
222001 if(dir==right)
3520 {
3521 61390 check_slash_block(wx+wxsz,wy+8);
3522 61390 check_slash_block(wx+wxsz-8,wy+8);
3523 //layer 1
3524 61390 check_slash_block_layer(wx+wxsz,wy+8,1);
3525 61390 check_slash_block_layer(wx+wxsz-8,wy+8,1);
3526 //layer 2
3527 61390 check_slash_block_layer(wx+wxsz,wy+8,2);
3528 61390 check_slash_block_layer(wx+wxsz-8,wy+8,2);
3529 61390 }
3530 222001 }
3531
2/2
✓ Branch 0 taken 10628 times.
✓ Branch 1 taken 1344 times.
11972 else if(attack==wWand)
3532 {
3533
1/2
✓ Branch 0 taken 10628 times.
✗ Branch 1 not taken.
10628 if(attackclk == 5)
3534 {
3535 for(int32_t q=0; q<176; q++)
3536 {
3537 set_bit(screengrid,q,0);
3538 set_bit(screengrid_layer[0],q,0);
3539 set_bit(screengrid_layer[1],q,0);
3540 }
3541
3542 for(dword q = MAXFFCS/8; q > 0; --q)
3543 ffcgrid[q-1] = 0;
3544 }
3545
3546 // cutable blocks
3547
4/4
✓ Branch 0 taken 1632 times.
✓ Branch 1 taken 8996 times.
✓ Branch 2 taken 909 times.
✓ Branch 3 taken 723 times.
10628 if(dir==up && (x.getInt()&15)==0)
3548 {
3549 723 check_wand_block(wx,wy);
3550 723 check_wand_block(wx,wy+8);
3551 723 }
3552
5/8
✓ Branch 0 taken 909 times.
✓ Branch 1 taken 8996 times.
✓ Branch 2 taken 621 times.
✓ Branch 3 taken 288 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 621 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9905 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3553 {
3554 909 check_wand_block(wx,wy);
3555 909 check_wand_block(wx,wy+8);
3556 909 check_wand_block(wx+8,wy);
3557 909 check_wand_block(wx+8,wy+8);
3558 909 }
3559
3560
4/4
✓ Branch 0 taken 1395 times.
✓ Branch 1 taken 9233 times.
✓ Branch 2 taken 654 times.
✓ Branch 3 taken 741 times.
10628 if(dir==down && (x.getInt()&15)==0)
3561 {
3562 741 check_wand_block(wx,wy+wysz-8);
3563 741 check_wand_block(wx,wy+wysz);
3564 741 }
3565
5/8
✓ Branch 0 taken 654 times.
✓ Branch 1 taken 9233 times.
✓ Branch 2 taken 135 times.
✓ Branch 3 taken 519 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 135 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9887 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3566 {
3567 654 check_wand_block(wx,wy+wysz-8);
3568 654 check_wand_block(wx,wy+wysz);
3569 654 check_wand_block(wx+8,wy+wysz-8);
3570 654 check_wand_block(wx+8,wy+wysz);
3571 654 }
3572
3573
2/2
✓ Branch 0 taken 6119 times.
✓ Branch 1 taken 4509 times.
10628 if(dir==left)
3574 {
3575 4509 check_wand_block(wx,y+8);
3576 4509 check_wand_block(wx+8,y+8);
3577 4509 }
3578
3579
2/2
✓ Branch 0 taken 7536 times.
✓ Branch 1 taken 3092 times.
10628 if(dir==right)
3580 {
3581 3092 check_wand_block(wx+wxsz,y+8);
3582 3092 check_wand_block(wx+wxsz-8,y+8);
3583 3092 }
3584 10628 }
3585
4/8
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1260 times.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1260 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1344 else if((attack==wHammer) && ((attackclk==15) || ( spins==1 && attackclk >=15 ))) //quake hammer should be spins == 1
3586 //else if((attack==wHammer) && (attackclk==15))
3587 //reverting this, because it breaks multiple-hit pegs
3588 //else if((attack==wHammer) && (attackclk>=15)) //>= instead of == for time it takes to charge up hammer with quake scrolls.
3589 {
3590 // poundable blocks
3591
2/2
✓ Branch 0 taken 14784 times.
✓ Branch 1 taken 84 times.
14868 for(int32_t q=0; q<176; q++)
3592 {
3593 14784 set_bit(screengrid,q,0);
3594 14784 set_bit(screengrid_layer[0],q,0);
3595 14784 set_bit(screengrid_layer[1],q,0);
3596 14784 }
3597
3598
2/2
✓ Branch 0 taken 1344 times.
✓ Branch 1 taken 84 times.
1428 for(dword q = MAXFFCS/8; q > 0; --q)
3599 1344 ffcgrid[q-1] = 0;
3600
3601
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 23 times.
84 if(dir==up && (x.getInt()&15)==0)
3602 {
3603 23 check_pound_block(wx,wy);
3604 23 check_pound_block(wx,wy+8);
3605 23 }
3606
3/8
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 57 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
61 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3607 {
3608 4 check_pound_block(wx,wy);
3609 4 check_pound_block(wx,wy+8);
3610 4 check_pound_block(wx+8,wy);
3611 4 check_pound_block(wx+8,wy+8);
3612 4 }
3613
3614
4/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 15 times.
84 if(dir==down && (x.getInt()&15)==0)
3615 {
3616 15 check_pound_block(wx,wy+wysz-8);
3617 15 check_pound_block(wx,wy+wysz);
3618 15 }
3619
3/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
69 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3620 {
3621 2 check_pound_block(wx,wy+wysz-8);
3622 2 check_pound_block(wx,wy+wysz);
3623 2 check_pound_block(wx+8,wy+wysz-8);
3624 2 check_pound_block(wx+8,wy+wysz);
3625 2 }
3626
3627
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 2 times.
84 if(dir==left)
3628 {
3629 2 check_pound_block(wx,y+8);
3630 2 check_pound_block(wx+8,y+8);
3631 2 }
3632
3633
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 38 times.
84 if(dir==right)
3634 {
3635 38 check_pound_block(wx+wxsz,y+8);
3636 38 check_pound_block(wx+wxsz-8,y+8);
3637 38 }
3638 84 }
3639 else
3640 {
3641 1260 return false;
3642 }
3643
3644 232713 return true;
3645 3394919 }
3646
3647 1178504 void HeroClass::check_slash_block_layer(int32_t bx, int32_t by, int32_t layer)
3648 {
3649
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 1178128 times.
1178504 if(!(get_bit(quest_rules,qr_BUSHESONLAYERS1AND2)))
3650 {
3651 //zprint("bit off\n");
3652 1178128 return;
3653 }
3654 //keep things inside the screen boundaries
3655 376 bx=vbound(bx, 0, 255);
3656 376 by=vbound(by, 0, 176);
3657 376 int32_t fx=vbound(bx, 0, 255);
3658 376 int32_t fy=vbound(by, 0, 176);
3659 //first things first
3660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 376 times.
376 if(attack!=wSword)
3661 return;
3662
3663
3/6
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 28 times.
404 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3664
3/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 348 times.
376 || (attackclk>SWORDTAPFRAME && tapping))
3665 return;
3666
3667 //find out which combo row/column the coordinates are in
3668 376 bx &= 0xF0;
3669 376 by &= 0xF0;
3670
3671
3672 376 int32_t flag = MAPFLAGL(layer,bx,by);
3673 376 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
3674 376 int32_t cid = MAPCOMBOL(layer,bx,by);
3675 376 int32_t type = combobuf[cid].type;
3676
1/2
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
376 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
3677 type = cNONE;
3678 //zprint("cid is: %d\n", cid);
3679 //zprint("type is: %d\n", type);
3680 376 int32_t i = (bx>>4) + by;
3681
3682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 376 times.
376 if(i > 175)
3683 return;
3684
3685 376 bool ignorescreen=false;
3686
3687
2/4
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
376 if((get_bit(screengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
3688 376 return;
3689
3690 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
3691
3692 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid_layer[layer-1],i,1);
3693 if(isCuttableNextType(type))
3694 {
3695 FFCore.tempScreens[layer]->data[i]++;
3696 }
3697 else
3698 {
3699 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
3700 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
3701 FFCore.tempScreens[layer]->sflag[i] = 0;
3702 }
3703 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
3704 {
3705 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
3706 sfx(tmpscr->secretsfx);
3707 }
3708 else if(isCuttableItemType(type))
3709 {
3710 int32_t it = -1;
3711 int32_t thedropset = -1;
3712
3713 //select_dropitem( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) ? (combobuf[MAPCOMBO(bx,by)-1].attributes[1])/10000L : 12, bx, by);
3714 if ( (combobuf[cid].usrflags&cflag2) )
3715 {
3716 if(combobuf[cid].usrflags&cflag11)
3717 it = combobuf[cid].attribytes[1];
3718 else
3719 {
3720 it = select_dropitem(combobuf[cid].attribytes[1]);
3721 thedropset = combobuf[cid].attribytes[1];
3722 }
3723 }
3724 else
3725 {
3726 it = select_dropitem(12);
3727 thedropset = 12;
3728 }
3729 if(it!=-1)
3730 {
3731 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
3732 itm->from_dropset = thedropset;
3733 items.add(itm);
3734 }
3735 }
3736
3737 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
3738
3739 if(get_bit(quest_rules,qr_MORESOUNDS))
3740 {
3741 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
3742 {
3743 if (combobuf[cid].usrflags&cflag3)
3744 {
3745 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3746 }
3747 }
3748 else
3749 {
3750 if (combobuf[cid].usrflags&cflag3)
3751 {
3752 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3753 }
3754 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
3755 }
3756 }
3757
3758 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
3759 if(decotype > 3) decotype = 0;
3760 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
3761 switch(decotype)
3762 {
3763 case -2: break; //nothing
3764 case -1:
3765 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
3766 break;
3767 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
3768 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
3769 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
3770 }
3771 1178504 }
3772
3773 540748 void HeroClass::check_slash_block(int32_t bx, int32_t by)
3774 {
3775 //keep things inside the screen boundaries
3776 540748 bx=vbound(bx, 0, 255);
3777 540748 by=vbound(by, 0, 176);
3778 540748 int32_t fx=vbound(bx, 0, 255);
3779 540748 int32_t fy=vbound(by, 0, 176);
3780 //first things first
3781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 540748 times.
540748 if(attack!=wSword)
3782 return;
3783
3784
4/6
✓ Branch 0 taken 540748 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 540748 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 64660 times.
605660 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3785
4/4
✓ Branch 0 taken 536886 times.
✓ Branch 1 taken 3862 times.
✓ Branch 2 taken 64912 times.
✓ Branch 3 taken 471974 times.
540748 || (attackclk>SWORDTAPFRAME && tapping))
3786 4114 return;
3787
3788 //find out which combo row/column the coordinates are in
3789 536634 bx &= 0xF0;
3790 536634 by &= 0xF0;
3791
3792 536634 int32_t type = COMBOTYPE(bx,by);
3793 536634 int32_t type2 = FFCOMBOTYPE(fx,fy);
3794 536634 int32_t flag = MAPFLAG(bx,by);
3795 536634 int32_t flag2 = MAPCOMBOFLAG(bx,by);
3796 536634 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
3797 536634 int32_t cid = MAPCOMBO(bx,by);
3798 536634 int32_t i = (bx>>4) + by;
3799
3800
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 536620 times.
536634 if(i > 175)
3801 14 return;
3802
3803 536620 bool ignorescreen=false;
3804 536620 bool ignoreffc=false;
3805
3806
2/2
✓ Branch 0 taken 8135 times.
✓ Branch 1 taken 528485 times.
536620 if(get_bit(screengrid, i) != 0)
3807 {
3808 8135 ignorescreen = true;
3809 8135 }
3810
1/2
✓ Branch 0 taken 528485 times.
✗ Branch 1 not taken.
528485 else if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
3811 ignorescreen = true;
3812
3813 536620 int32_t current_ffcombo = getFFCAt(fx,fy);
3814
3815
3816
3/4
✓ Branch 0 taken 1043 times.
✓ Branch 1 taken 535577 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1043 times.
536620 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
3817 {
3818 535577 ignoreffc = true;
3819 535577 }
3820
1/2
✓ Branch 0 taken 1043 times.
✗ Branch 1 not taken.
1043 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
3821 ignoreffc = true;
3822
3823
3/4
✓ Branch 0 taken 534092 times.
✓ Branch 1 taken 2528 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 534088 times.
1070708 if(!isCuttableType(type) &&
3824
6/6
✓ Branch 0 taken 697 times.
✓ Branch 1 taken 533395 times.
✓ Branch 2 taken 534088 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 39 times.
✓ Branch 5 taken 534049 times.
534092 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
3825 {
3826 534088 ignorescreen = true;
3827 534088 }
3828
3829
2/4
✓ Branch 0 taken 536620 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 536620 times.
1073240 if(!isCuttableType(type2) &&
3830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 536620 times.
536620 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
3831 {
3832 536620 ignoreffc = true;
3833 536620 }
3834
3835 536620 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
3836
3837
3/4
✓ Branch 0 taken 5576 times.
✓ Branch 1 taken 531044 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5576 times.
536620 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
3838 536620 byte skipsecrets = 0;
3839
3840
2/2
✓ Branch 0 taken 534115 times.
✓ Branch 1 taken 2505 times.
536620 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
3841 {
3842
2/2
✓ Branch 0 taken 2466 times.
✓ Branch 1 taken 39 times.
2505 if (get_bit(quest_rules,qr_OLD_SLASHNEXT_SECRETS))
3843 {
3844 2466 skipsecrets = 0;
3845 2466 }
3846 39 else skipsecrets = 1; ;
3847 2505 }
3848
3849
6/6
✓ Branch 0 taken 989 times.
✓ Branch 1 taken 535631 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 950 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 51 times.
536620 if(!ignorescreen && (!skipsecrets || !get_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS)))
3850 {
3851
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1001 if((flag >= 16)&&(flag <= 31) && !skipsecrets)
3852 {
3853 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
3854 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
3855 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
3856 }
3857
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 997 times.
1001 else if(flag == mfARMOS_SECRET)
3858 {
3859 4 s->data[i] = s->secretcombo[sSTAIRS];
3860 4 s->cset[i] = s->secretcset[sSTAIRS];
3861 4 s->sflag[i] = s->secretflag[sSTAIRS];
3862 4 sfx(tmpscr->secretsfx);
3863 4 }
3864
4/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 987 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 981 times.
997 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
3865 {
3866
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 4 times.
26 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3867 {
3868 10 findentrance(bx,by,mfSWORD+i2,true);
3869 10 }
3870
3871 4 findentrance(bx,by,mfSTRIKE,true);
3872 4 }
3873
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 981 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
981 else if(((flag2 >= 16)&&(flag2 <= 31)))
3874 {
3875 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
3876 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
3877 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
3878 }
3879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 981 times.
981 else if(flag2 == mfARMOS_SECRET)
3880 {
3881 s->data[i] = s->secretcombo[sSTAIRS];
3882 s->cset[i] = s->secretcset[sSTAIRS];
3883 s->sflag[i] = s->secretflag[sSTAIRS];
3884 sfx(tmpscr->secretsfx);
3885 }
3886
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 981 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 981 times.
981 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
3887 {
3888 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3889 {
3890 findentrance(bx,by,mfSWORD+i2,true);
3891 }
3892
3893 findentrance(bx,by,mfSTRIKE,true);
3894 }
3895 else
3896 {
3897
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 21 times.
981 if(isCuttableNextType(type))
3898 {
3899 960 s->data[i]++;
3900 960 }
3901 else
3902 {
3903 21 s->data[i] = s->undercombo;
3904 21 s->cset[i] = s->undercset;
3905 21 s->sflag[i] = 0;
3906 }
3907
3908 //pausenow=true;
3909 }
3910 989 }
3911
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 535643 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
535643 else if(!ignorescreen && skipsecrets)
3912 {
3913 if(isCuttableNextType(type))
3914 {
3915 s->data[i]++;
3916 }
3917 else
3918 {
3919 s->data[i] = s->undercombo;
3920 s->cset[i] = s->undercset;
3921 s->sflag[i] = 0;
3922 }
3923 }
3924
3925
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 536632 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 536632 times.
536632 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
3926 {
3927 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3928 {
3929 findentrance(bx,by,mfSWORD+i2,true);
3930 }
3931
3932 findentrance(fx,fy,mfSTRIKE,true);
3933 }
3934
1/2
✓ Branch 0 taken 536632 times.
✗ Branch 1 not taken.
536632 else if(!ignoreffc)
3935 {
3936 if(isCuttableNextType(type2))
3937 {
3938 s->ffcs[current_ffcombo].incData(1);
3939 }
3940 else
3941 {
3942 s->ffcs[current_ffcombo].setData(s->undercombo);
3943 s->ffcs[current_ffcombo].cset = s->undercset;
3944 }
3945 }
3946
3947
2/2
✓ Branch 0 taken 535643 times.
✓ Branch 1 taken 989 times.
536632 if(!ignorescreen)
3948 {
3949
3/4
✓ Branch 0 taken 943 times.
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 943 times.
989 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
3950
3951
5/8
✓ Branch 0 taken 983 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 983 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 6 times.
989 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
3952 {
3953
4/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
6 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
3954 6 sfx(tmpscr->secretsfx);
3955 6 }
3956
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 977 times.
983 else if(isCuttableItemType(type))
3957 {
3958 977 int32_t it = -1;
3959 977 int32_t thedropset = -1;
3960
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 955 times.
977 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
3961 {
3962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if ( combobuf[cid].usrflags&cflag11 )
3963 {
3964 it = combobuf[cid].attribytes[1];
3965 }
3966 else
3967 {
3968 22 it = select_dropitem(combobuf[cid].attribytes[1]);
3969 22 thedropset = combobuf[cid].attribytes[1];
3970 }
3971 22 }
3972 else
3973 {
3974 955 it = select_dropitem(12);
3975 955 thedropset = 12;
3976 }
3977
3978
2/2
✓ Branch 0 taken 739 times.
✓ Branch 1 taken 238 times.
977 if(it!=-1)
3979 {
3980
4/8
✓ Branch 0 taken 238 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 238 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 238 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 238 times.
✗ Branch 7 not taken.
238 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
3981 238 itm->from_dropset = thedropset;
3982 238 items.add(itm);
3983 238 }
3984 977 }
3985
3986 989 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
3987
3988
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 181 times.
989 if(get_bit(quest_rules,qr_MORESOUNDS))
3989 {
3990
6/6
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 32 times.
181 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
3991 {
3992
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 22 times.
32 if (combobuf[cid].usrflags&cflag3)
3993 {
3994 22 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3995 22 }
3996 32 }
3997 else
3998 {
3999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if (combobuf[cid].usrflags&cflag3)
4000 {
4001 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4002 }
4003 149 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4004 }
4005 181 }
4006
4007
3/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 869 times.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
989 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4008
1/2
✓ Branch 0 taken 989 times.
✗ Branch 1 not taken.
989 if(decotype > 3) decotype = 0;
4009
7/8
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 869 times.
✓ Branch 2 taken 300 times.
✓ Branch 3 taken 569 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 569 times.
✓ Branch 6 taken 531 times.
✓ Branch 7 taken 38 times.
989 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4010
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 399 times.
✓ Branch 4 taken 21 times.
✓ Branch 5 taken 531 times.
989 switch(decotype)
4011 {
4012 38 case -2: break; //nothing
4013 case -1:
4014 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4015 break;
4016
3/6
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 399 times.
✗ Branch 5 not taken.
399 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4017
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
21 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4018
3/6
✓ Branch 0 taken 531 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 531 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 531 times.
✗ Branch 5 not taken.
531 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4019 }
4020 989 }
4021
4022
1/2
✓ Branch 0 taken 536632 times.
✗ Branch 1 not taken.
536632 if(!ignoreffc)
4023 {
4024 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4025
4026 if(isCuttableItemType(type2))
4027 {
4028 int32_t it=-1;
4029 int32_t thedropset=-1;
4030 if ( (combobuf[cid].usrflags&cflag2) )
4031 {
4032 if(combobuf[cid].usrflags&cflag11)
4033 it = combobuf[cid].attribytes[1];
4034 else
4035 {
4036 it = select_dropitem(combobuf[cid].attribytes[1]);
4037 thedropset = combobuf[cid].attribytes[1];
4038 }
4039 }
4040 else
4041 {
4042 int32_t r=zc_oldrand()%100;
4043
4044 if(r<15)
4045 {
4046 it=iHeart; // 15%
4047 }
4048 else if(r<35)
4049 {
4050 it=iRupy; // 20%
4051 }
4052 }
4053
4054 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4055 {
4056 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4057 itm->from_dropset = thedropset;
4058 items.add(itm);
4059 }
4060 }
4061
4062 if(get_bit(quest_rules,qr_MORESOUNDS))
4063 {
4064 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4065 {
4066 if (combobuf[cid].usrflags&cflag3)
4067 {
4068 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4069 }
4070 }
4071 else
4072 {
4073 if (combobuf[cid].usrflags&cflag3)
4074 {
4075 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4076 }
4077 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4078 }
4079 }
4080
4081 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4082 if(decotype > 3) decotype = 0;
4083 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4084 switch(decotype)
4085 {
4086 case -2: break; //nothing
4087 case -1:
4088 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4089 break;
4090 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4091 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4092 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4093 }
4094 }
4095 540760 }
4096
4097 8570759 void HeroClass::check_wpn_triggers(int32_t bx, int32_t by, weapon *w)
4098 {
4099 /*
4100 int32_t par_item = w->parentitem;
4101 al_trace("check_wpn_triggers(weapon *w): par_item is: %d\n", par_item);
4102 int32_t usewpn = -1;
4103 if ( par_item > -1 )
4104 {
4105 usewpn = itemsbuf[par_item].useweapon;
4106 }
4107 else if ( par_item == -1 && w->ScriptGenerated )
4108 {
4109 usewpn = w->useweapon;
4110 }
4111 al_trace("check_wpn_triggers(weapon *w): usewpn is: %d\n", usewpn);
4112
4113 */
4114 8570759 bx=vbound(bx, 0, 255);
4115 8570759 by=vbound(by, 0, 176);
4116 8570759 int32_t cid = MAPCOMBO(bx,by);
4117
3/30
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 201168 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 8368343 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 1248 times.
✗ Branch 29 not taken.
8570759 switch(w->useweapon)
4118 {
4119 case wArrow:
4120 findentrance(bx,by,mfARROW,true);
4121 findentrance(bx,by,mfSARROW,true);
4122 findentrance(bx,by,mfGARROW,true);
4123 break;
4124 case wBeam:
4125 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4126 break;
4127 case wHookshot:
4128 findentrance(bx,by,mfHOOKSHOT,true);
4129 break;
4130 case wBrang:
4131 for(int32_t i = 0; i <3; i++) findentrance(bx,by,mfBRANG+i,true);
4132 break;
4133 case wMagic:
4134 findentrance(bx,by,mfWANDMAGIC,true);
4135 break;
4136 case wRefMagic:
4137 findentrance(bx,by,mfWANDMAGIC,true);
4138 break;
4139 case wRefBeam:
4140 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4141 break;
4142 //reflected magic needs to happen in mirrors:
4143 //
4144 //findentrance(bx,by,mfREFMAGIC,true)
4145 case wRefFireball:
4146 findentrance(bx,by,mfREFFIREBALL,true);
4147 break;
4148 case wBomb:
4149 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfBOMB,true);
4150 break;
4151
4152 case wSBomb:
4153 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfSBOMB,true);
4154 break;
4155
4156 case wFire:
4157 201168 findentrance(bx,by,mfBCANDLE,true);
4158 201168 findentrance(bx,by,mfRCANDLE,true);
4159 201168 findentrance(bx,by,mfWANDFIRE,true);
4160 /* if we want the weapon to die
4161 if (findentrance(bx,by,mfBCANDLE,true) ) dead = 1;
4162 if (findentrance(bx,by,mfRCANDLE,true) ) dead = 1;
4163 if (findentrance(bx,by,mfWANDFIRE,true)) dead = 1;
4164 */
4165 201168 break;
4166
4167 case wScript1:
4168 break;
4169 case wScript2:
4170 break;
4171 case wScript3:
4172 break;
4173 case wScript4:
4174 break;
4175 case wScript5:
4176 break;
4177 case wScript6:
4178 break;
4179 case wScript7:
4180 break;
4181 case wScript8:
4182 break;
4183 case wScript9:
4184 break;
4185 case wScript10:
4186 break;
4187 case wIce:
4188 break;
4189 case wCByrna:
4190 break;
4191 case wWhistle:
4192 break;
4193 case wSSparkle:
4194 case wFSparkle:
4195 break;
4196 case wWind:
4197 break;
4198 case wBait:
4199 break;
4200 case wFlame:
4201 case wThrown:
4202 case wBombos:
4203 case wEther:
4204 case wQuake:
4205 case wSwordLA:
4206 case wSword180:
4207 case wStomp:
4208 break;
4209 case wSword:
4210 case wWand:
4211 //case wCandle:
4212 case wHSHandle:
4213 case wLitBomb:
4214 case wLitSBomb:
4215 1248 break;
4216 8368343 default: break;
4217
4218 }
4219 8570759 }
4220
4221 17141518 void HeroClass::check_slash_block_layer2(int32_t bx, int32_t by, weapon *w, int32_t layer)
4222 {
4223
4224
2/2
✓ Branch 0 taken 34560 times.
✓ Branch 1 taken 17106958 times.
17141518 if(!(get_bit(quest_rules,qr_BUSHESONLAYERS1AND2)))
4225 {
4226 //zprint("bit off\n");
4227 17106958 return;
4228 }
4229 //keep things inside the screen boundaries
4230 34560 bx=vbound(bx, 0, 255);
4231 34560 by=vbound(by, 0, 176);
4232 34560 int32_t fx=vbound(bx, 0, 255);
4233 34560 int32_t fy=vbound(by, 0, 176);
4234 //first things first
4235
1/2
✓ Branch 0 taken 34560 times.
✗ Branch 1 not taken.
34560 if(w->useweapon != wSword)
4236 34560 return;
4237
4238 //find out which combo row/column the coordinates are in
4239 bx &= 0xF0;
4240 by &= 0xF0;
4241
4242
4243 int32_t flag = MAPFLAGL(layer,bx,by);
4244 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
4245 int32_t cid = MAPCOMBOL(layer,bx,by);
4246 int32_t type = combobuf[cid].type;
4247 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4248 type = cNONE;
4249 //zprint("cid is: %d\n", cid);
4250 //zprint("type is: %d\n", type);
4251 int32_t i = (bx>>4) + by;
4252
4253 if(i > 175)
4254 return;
4255
4256 if((get_bit(w->wscreengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
4257 {
4258 return;
4259 //ignorescreen = true;
4260 //zprint("ignoring\n");
4261 }
4262
4263 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4264
4265 {
4266 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid_layer[layer-1],i,1);
4267 if(isCuttableNextType(type) || isCuttableNextType(type))
4268 {
4269 FFCore.tempScreens[layer]->data[i]++;
4270 }
4271 else
4272 {
4273 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
4274 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
4275 FFCore.tempScreens[layer]->sflag[i] = 0;
4276 }
4277 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4278 {
4279 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4280 sfx(tmpscr->secretsfx);
4281 }
4282 else if(isCuttableItemType(type))
4283 {
4284 int32_t it = -1;
4285 int32_t thedropset = -1;
4286
4287 if ( (combobuf[cid].usrflags&cflag2) )
4288 {
4289 if(combobuf[cid].usrflags&cflag11)
4290 it = combobuf[cid].attribytes[1];
4291 else
4292 {
4293 it = select_dropitem(combobuf[cid].attribytes[1]);
4294 thedropset = combobuf[cid].attribytes[1];
4295 }
4296 }
4297 else
4298 {
4299 it = select_dropitem(12);
4300 thedropset = 12;
4301 }
4302
4303 if(it!=-1)
4304 {
4305 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4306 itm->from_dropset = thedropset;
4307 items.add(itm);
4308 }
4309 }
4310
4311 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
4312
4313 if(get_bit(quest_rules,qr_MORESOUNDS))
4314 {
4315 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4316 {
4317 if (combobuf[cid].usrflags&cflag3)
4318 {
4319 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4320 }
4321 }
4322 else
4323 {
4324 if (combobuf[cid].usrflags&cflag3)
4325 {
4326 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4327 }
4328 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4329 }
4330 }
4331
4332 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4333 if(decotype > 3) decotype = 0;
4334 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4335 switch(decotype)
4336 {
4337 case -2: break; //nothing
4338 case -1:
4339 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4340 break;
4341 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4342 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4343 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4344 }
4345
4346 }
4347
4348 17141518 }
4349
4350 8570759 void HeroClass::check_slash_block2(int32_t bx, int32_t by, weapon *w)
4351 {
4352 /*
4353 int32_t par_item = w->parentitem;
4354 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4355 int32_t usewpn = -1;
4356 if ( par_item > -1 )
4357 {
4358 usewpn = itemsbuf[par_item].useweapon;
4359 }
4360 else if ( par_item == -1 && w->ScriptGenerated )
4361 {
4362 usewpn = w->useweapon;
4363 }
4364 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
4365 */
4366
4367
4368 //keep things inside the screen boundaries
4369 8570759 bx=vbound(bx, 0, 255);
4370 8570759 by=vbound(by, 0, 176);
4371 8570759 int32_t fx=vbound(bx, 0, 255);
4372 8570759 int32_t fy=vbound(by, 0, 176);
4373 8570759 int32_t cid = MAPCOMBO(bx,by);
4374
4375 //find out which combo row/column the coordinates are in
4376 8570759 bx &= 0xF0;
4377 8570759 by &= 0xF0;
4378
4379 8570759 int32_t type = COMBOTYPE(bx,by);
4380 8570759 int32_t type2 = FFCOMBOTYPE(fx,fy);
4381 8570759 int32_t flag = MAPFLAG(bx,by);
4382 8570759 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4383 8570759 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4384
1/2
✓ Branch 0 taken 8570759 times.
✗ Branch 1 not taken.
8570759 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4385 type = cNONE;
4386 8570759 byte dontignore = 0;
4387 8570759 byte dontignoreffc = 0;
4388
4389
4/4
✓ Branch 0 taken 175720 times.
✓ Branch 1 taken 8395039 times.
✓ Branch 2 taken 175421 times.
✓ Branch 3 taken 299 times.
8570759 if (isCuttableType(type) && MatchComboTrigger(w, combobuf, cid))
4390 {
4391 299 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4392 299 dontignore = 1;
4393 299 }
4394
4395 /*to-do, ffcs
4396 if (isCuttableType(type2) && MatchComboTrigger(w, combobuf, cid))
4397 {
4398 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4399 dontignoreffc = 1;
4400 }*/
4401
4/4
✓ Branch 0 taken 8569511 times.
✓ Branch 1 taken 1248 times.
✓ Branch 2 taken 8569212 times.
✓ Branch 3 taken 299 times.
8570759 if(w->useweapon != wSword && !dontignore) return;
4402
4403
4404 1547 int32_t i = (bx>>4) + by;
4405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
1547 if (get_bit(w->wscreengrid,(((bx>>4) + by))) ) return;
4406
4407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
1547 if(i > 175)
4408 return;
4409
4410 1547 bool ignorescreen=false;
4411 1547 bool ignoreffc=false;
4412
4413
1/2
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
1547 if(get_bit(w->wscreengrid, i) != 0)
4414 {
4415 ignorescreen = true; dontignore = 0;
4416 }
4417
4418 1547 int32_t current_ffcombo = getFFCAt(fx,fy);
4419
4420
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1545 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
1547 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4421 {
4422 1545 ignoreffc = true;
4423 1545 }
4424
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
4425 type2 = cNONE;
4426
3/4
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1248 times.
2795 if(!isCuttableType(type) &&
4427
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1248 times.
✓ Branch 2 taken 1248 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1248 times.
1248 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
4428 {
4429 1248 ignorescreen = true;
4430 1248 }
4431
4432
2/4
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1547 times.
3094 if(!isCuttableType(type2) &&
4433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
1547 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
4434 {
4435 1547 ignoreffc = true;
4436 1547 }
4437
4438 1547 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4439
4440
4/4
✓ Branch 0 taken 1254 times.
✓ Branch 1 taken 293 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 1248 times.
1547 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4441 1547 byte skipsecrets = 0;
4442
2/2
✓ Branch 0 taken 700 times.
✓ Branch 1 taken 249 times.
1547 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
4443 {
4444
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (get_bit(quest_rules,qr_OLD_SLASHNEXT_SECRETS))
4445 {
4446 249 skipsecrets = 0;
4447 249 }
4448 else skipsecrets = 1;
4449 249 }
4450
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 949 times.
✓ Branch 2 taken 1248 times.
✓ Branch 3 taken 1248 times.
✓ Branch 4 taken 1248 times.
✓ Branch 5 taken 949 times.
949 if((!skipsecrets || !get_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS)) && (!ignorescreen || dontignore))
4451 {
4452
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2197 if((flag >= 16)&&(flag <= 31)&&!skipsecrets)
4453 {
4454 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4455 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4456 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4457 }
4458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 else if(flag == mfARMOS_SECRET)
4459 {
4460 s->data[i] = s->secretcombo[sSTAIRS];
4461 s->cset[i] = s->secretcset[sSTAIRS];
4462 s->sflag[i] = s->secretflag[sSTAIRS];
4463 sfx(tmpscr->secretsfx);
4464 }
4465
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
299 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
4466 {
4467 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4468 {
4469 findentrance(bx,by,mfSWORD+i2,true);
4470 }
4471
4472 findentrance(bx,by,mfSTRIKE,true);
4473 }
4474
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
299 else if(((flag2 >= 16)&&(flag2 <= 31)))
4475 {
4476 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4477 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4478 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4479 }
4480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 else if(flag2 == mfARMOS_SECRET)
4481 {
4482 s->data[i] = s->secretcombo[sSTAIRS];
4483 s->cset[i] = s->secretcset[sSTAIRS];
4484 s->sflag[i] = s->secretflag[sSTAIRS];
4485 sfx(tmpscr->secretsfx);
4486 }
4487
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
299 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
4488 {
4489 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4490 {
4491 findentrance(bx,by,mfSWORD+i2,true);
4492 }
4493
4494 findentrance(bx,by,mfSTRIKE,true);
4495 }
4496 else
4497 {
4498
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 50 times.
299 if(isCuttableNextType(type))
4499 {
4500 249 s->data[i]++;
4501 249 }
4502 else
4503 {
4504 50 s->data[i] = s->undercombo;
4505 50 s->cset[i] = s->undercset;
4506 50 s->sflag[i] = 0;
4507 }
4508
4509 //pausenow=true;
4510 }
4511 299 }
4512
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1248 else if(skipsecrets && (!ignorescreen || dontignore))
4513 {
4514 if(isCuttableNextType(type))
4515 {
4516 s->data[i]++;
4517 }
4518 else
4519 {
4520 s->data[i] = s->undercombo;
4521 s->cset[i] = s->undercset;
4522 s->sflag[i] = 0;
4523 }
4524 }
4525
4526
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1547 times.
1547 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
4527 {
4528 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4529 {
4530 findentrance(bx,by,mfSWORD+i2,true);
4531 }
4532
4533 findentrance(fx,fy,mfSTRIKE,true);
4534 }
4535
1/2
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
1547 else if(!ignoreffc)
4536 {
4537 if(isCuttableNextType(type2))
4538 {
4539 s->ffcs[current_ffcombo].incData(1);
4540 }
4541 else
4542 {
4543 s->ffcs[current_ffcombo].setData(s->undercombo);
4544 s->ffcs[current_ffcombo].cset = s->undercset;
4545 }
4546 }
4547
4548
3/4
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1248 times.
1547 if(!ignorescreen || dontignore)
4549 {
4550
3/4
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 88 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 211 times.
299 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid,i,1);
4551
4552
2/8
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
299 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4553 {
4554 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4555 sfx(tmpscr->secretsfx);
4556 }
4557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 else if(isCuttableItemType(type))
4558 {
4559 299 int32_t it = -1;
4560 299 int32_t thedropset = -1;
4561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
4562 {
4563 if ( combobuf[cid].usrflags&cflag11 )
4564 {
4565 it = combobuf[cid].attribytes[1];
4566 }
4567 else
4568 {
4569 it = select_dropitem(combobuf[cid].attribytes[1]);
4570 thedropset = combobuf[cid].attribytes[1];
4571 }
4572 }
4573 else
4574 {
4575 299 it = select_dropitem(12);
4576 299 thedropset = 12;
4577 }
4578
4579
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 99 times.
299 if(it!=-1)
4580 {
4581
4/8
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 99 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 99 times.
✗ Branch 7 not taken.
99 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4582 99 itm->from_dropset = thedropset;
4583 99 items.add(itm);
4584 99 }
4585 299 }
4586
4587
4588 299 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4589
4590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if(get_bit(quest_rules,qr_MORESOUNDS))
4591 {
4592
5/6
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 50 times.
✓ Branch 4 taken 161 times.
✗ Branch 5 not taken.
299 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4593 {
4594 if (combobuf[cid].usrflags&cflag3)
4595 {
4596 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4597 }
4598 }
4599 else
4600 {
4601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if (combobuf[cid].usrflags&cflag3)
4602 {
4603 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4604 }
4605 299 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4606 }
4607 299 }
4608
4609
2/4
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 299 times.
✗ Branch 3 not taken.
299 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4610
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 if(decotype > 3) decotype = 0;
4611
1/8
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
299 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4612
2/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✓ Branch 4 taken 50 times.
✗ Branch 5 not taken.
299 switch(decotype)
4613 {
4614 case -2: break; //nothing
4615 case -1:
4616 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4617 break;
4618
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
249 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4619
3/6
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50 times.
✗ Branch 5 not taken.
50 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4620 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4621 }
4622 299 }
4623
4624
1/2
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
1547 if(!ignoreffc)
4625 {
4626 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4627
4628 if(isCuttableItemType(type2))
4629 {
4630 int32_t it=-1;
4631 int32_t thedropset=-1;
4632 if ( (combobuf[cid].usrflags&cflag2) )
4633 {
4634 if(combobuf[cid].usrflags&cflag11)
4635 it = combobuf[cid].attribytes[1];
4636 else
4637 {
4638 it = select_dropitem(combobuf[cid].attribytes[1]);
4639 thedropset = combobuf[cid].attribytes[1];
4640 }
4641 }
4642 else
4643 {
4644 int32_t r=zc_oldrand()%100;
4645
4646 if(r<15)
4647 {
4648 it=iHeart; // 15%
4649 }
4650 else if(r<35)
4651 {
4652 it=iRupy; // 20%
4653 }
4654 }
4655
4656 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4657 {
4658 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4659 itm->from_dropset = thedropset;
4660 items.add(itm);
4661 }
4662 }
4663
4664 if(get_bit(quest_rules,qr_MORESOUNDS))
4665 {
4666 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4667 {
4668 if (combobuf[cid].usrflags&cflag3)
4669 {
4670 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4671 }
4672 }
4673 else
4674 {
4675 if (combobuf[cid].usrflags&cflag3)
4676 {
4677 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4678 }
4679 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4680 }
4681 }
4682
4683 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4684 if(decotype > 3) decotype = 0;
4685 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4686 switch(decotype)
4687 {
4688 case -2: break; //nothing
4689 case -1:
4690 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4691 break;
4692 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4693 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4694 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4695 }
4696 }
4697 8570759 }
4698
4699 8570759 void HeroClass::check_wand_block2(int32_t bx, int32_t by, weapon *w)
4700 {
4701 /*
4702 int32_t par_item = w->parentitem;
4703 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
4704 int32_t usewpn = -1;
4705 if ( par_item > -1 )
4706 {
4707 usewpn = itemsbuf[par_item].useweapon;
4708 }
4709 else if ( par_item == -1 && w->ScriptGenerated )
4710 {
4711 usewpn = w->useweapon;
4712 }
4713 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
4714 */
4715
4716 8570759 byte dontignore = 0;
4717 8570759 byte dontignoreffc = 0;
4718
4719
4720
4721
4722
4723 //keep things inside the screen boundaries
4724 8570759 bx=vbound(bx, 0, 255);
4725 8570759 by=vbound(by, 0, 176);
4726 8570759 int32_t fx=vbound(bx, 0, 255);
4727 8570759 int32_t fy=vbound(by, 0, 176);
4728 8570759 int32_t cid = MAPCOMBO(bx,by);
4729
4730 //Z_scripterrlog("check_wand_block2 MatchComboTrigger() returned: %d\n", );
4731
3/4
✓ Branch 0 taken 8570759 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 464 times.
✓ Branch 3 taken 8570295 times.
8570759 if(w->useweapon != wWand && !MatchComboTrigger (w, combobuf, cid)) return;
4732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 464 times.
464 if ( MatchComboTrigger (w, combobuf, cid) ) dontignore = 1;
4733
4734 //first things first
4735
2/4
✓ Branch 0 taken 464 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 464 times.
464 if(z>8||fakez>8) return;
4736
4737 //find out which combo row/column the coordinates are in
4738 464 bx &= 0xF0;
4739 464 by &= 0xF0;
4740
4741 464 int32_t flag = MAPFLAG(bx,by);
4742 464 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4743 464 int32_t flag3=0;
4744 464 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
4745 464 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
4746 464 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
4747 464 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
4748
4749
4/8
✓ Branch 0 taken 464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 464 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 464 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 464 times.
464 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
4750 flag3=mfWAND;
4751
4752
4/8
✓ Branch 0 taken 464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 464 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 464 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 464 times.
464 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
4753 flag3=mfSTRIKE;
4754
4755 464 int32_t i = (bx>>4) + by;
4756
4757
6/12
✓ Branch 0 taken 464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 464 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 464 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 464 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 464 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 464 times.
464 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
4758 464 return;
4759
4760 if(i > 175)
4761 return;
4762
4763 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4764
4765 //findentrance(bx,by,mfWAND,true);
4766 //findentrance(bx,by,mfSTRIKE,true);
4767 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
4768 {
4769 if(flag3==mfWAND||flag3==mfSTRIKE)
4770 {
4771 findentrance(fx,fy,mfWAND,true);
4772 findentrance(fx,fy,mfSTRIKE,true);
4773 }
4774 }
4775
4776 if(dontignore) { findentrance(bx,by,mfWAND,true); }
4777
4778 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4779 8570759 }
4780
4781 8570759 void HeroClass::check_pound_block2(int32_t bx, int32_t by, weapon *w)
4782 {
4783 /*
4784 int32_t par_item = w->parentitem;
4785 al_trace("check_pound_block(weapon *w): par_item is: %d\n", par_item);
4786 int32_t usewpn = -1;
4787 if ( par_item > -1 )
4788 {
4789 usewpn = itemsbuf[par_item].useweapon;
4790 }
4791 else if ( par_item == -1 && w->ScriptGenerated )
4792 {
4793 usewpn = w->useweapon;
4794 }
4795 al_trace("check_pound_block(weapon *w): usewpn is: %d\n", usewpn);
4796 */
4797 //keep things inside the screen boundaries
4798 8570759 bx=vbound(bx, 0, 255);
4799 8570759 by=vbound(by, 0, 176);
4800 8570759 int32_t fx=vbound(bx, 0, 255);
4801 8570759 int32_t fy=vbound(by, 0, 176);
4802 8570759 int32_t cid = MAPCOMBO(bx,by);
4803 8570759 byte dontignore = MatchComboTrigger (w, combobuf, cid);
4804
3/4
✓ Branch 0 taken 8570759 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 464 times.
✓ Branch 3 taken 8570295 times.
8570759 if(w->useweapon != wHammer && !dontignore ) return;
4805
4806
4807
4808
4809 //first things first
4810
2/4
✓ Branch 0 taken 464 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 464 times.
464 if(z>8||fakez>8) return;
4811
4812 //find out which combo row/column the coordinates are in
4813 464 bx &= 0xF0;
4814 464 by &= 0xF0;
4815
4816 464 int32_t type = COMBOTYPE(bx,by);
4817 464 int32_t type2 = FFCOMBOTYPE(fx,fy);
4818 464 int32_t flag = MAPFLAG(bx,by);
4819 464 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4820 464 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4821 464 int32_t i = (bx>>4) + by;
4822
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 319 times.
464 if (get_bit(w->wscreengrid,(((bx>>4) + by))) ) return;
4823
4824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 319 times.
319 if(i > 175)
4825 return;
4826
4827 319 bool ignorescreen=false;
4828 319 bool ignoreffc=false;
4829 319 bool pound=false;
4830
4831
1/2
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
319 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4832 type = cNONE;
4833
5/10
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 319 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 319 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 319 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 319 times.
319 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
4834 319 ignorescreen = true; // Affect only FFCs
4835
4836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 319 times.
319 if(get_bit(w->wscreengrid, i) != 0)
4837 {
4838 ignorescreen = true; dontignore = 0;
4839 }
4840
4841 319 int32_t current_ffcombo = getFFCAt(fx,fy);
4842
4843
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 319 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
319 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4844 319 ignoreffc = true;
4845 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
4846 type2 = cNONE;
4847
3/6
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 319 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 319 times.
319 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
4848 319 ignoreffc = true;
4849
4850
2/4
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 319 times.
319 if(ignorescreen && ignoreffc) // Nothing to do.
4851 319 return;
4852
4853 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4854
4855 if(!ignorescreen || dontignore)
4856 {
4857 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
4858 {
4859 findentrance(bx,by,mfHAMMER,true);
4860 findentrance(bx,by,mfSTRIKE,true);
4861 }
4862 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
4863 {
4864 findentrance(bx,by,mfHAMMER,true);
4865 findentrance(bx,by,mfSTRIKE,true);
4866 }
4867 else if((flag >= 16)&&(flag <= 31))
4868 {
4869 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4870 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4871 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4872 }
4873 else if(flag == mfARMOS_SECRET)
4874 {
4875 s->data[i] = s->secretcombo[sSTAIRS];
4876 s->cset[i] = s->secretcset[sSTAIRS];
4877 s->sflag[i] = s->secretflag[sSTAIRS];
4878 sfx(tmpscr->secretsfx);
4879 }
4880 else if((flag2 >= 16)&&(flag2 <= 31))
4881 {
4882 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4883 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4884 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4885 }
4886 else if(flag2 == mfARMOS_SECRET)
4887 {
4888 s->data[i] = s->secretcombo[sSTAIRS];
4889 s->cset[i] = s->secretcset[sSTAIRS];
4890 s->sflag[i] = s->secretflag[sSTAIRS];
4891 sfx(tmpscr->secretsfx);
4892 }
4893 else pound = true;
4894 }
4895
4896 if(!ignoreffc)
4897 {
4898 if(flag3==mfHAMMER||flag3==mfSTRIKE)
4899 {
4900 findentrance(fx,fy,mfHAMMER,true);
4901 findentrance(fx,fy,mfSTRIKE,true);
4902 }
4903 else
4904 {
4905 s->ffcs[current_ffcombo].incData(1);
4906 }
4907 }
4908
4909 if(!ignorescreen || dontignore)
4910 {
4911 if(pound)
4912 s->data[i]+=1;
4913
4914 set_bit(w->wscreengrid,i,1);
4915
4916 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4917 {
4918 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4919 sfx(tmpscr->secretsfx);
4920 }
4921
4922 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
4923 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
4924
4925 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4926 }
4927
4928 if(!ignoreffc)
4929 {
4930 set_bit(ffcgrid,current_ffcombo,1);
4931
4932 if(type2==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
4933 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
4934 }
4935
4936 return;
4937 8570759 }
4938
4939 void HeroClass::check_slash_block(weapon *w)
4940 {
4941 //first things
4942
4943 int32_t par_item = w->parentitem;
4944 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4945 int32_t usewpn = -1;
4946 if ( par_item > -1 )
4947 {
4948 usewpn = itemsbuf[par_item].useweapon;
4949 }
4950 else if ( par_item == -1 && w->ScriptGenerated )
4951 {
4952 usewpn = w->useweapon;
4953 }
4954 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
4955 if(usewpn != wSword) return;
4956
4957
4958 int32_t bx = 0, by = 0;
4959 bx = ((int32_t)w->x) + (((int32_t)w->hxsz)/2);
4960 by = ((int32_t)w->y) + (((int32_t)w->hysz)/2);
4961 al_trace("check_slash_block(weapon *w): bx is: %d\n", bx);
4962 al_trace("check_slash_block(weapon *w): by is: %d\n", by);
4963 //keep things inside the screen boundaries
4964 bx=vbound(bx, 0, 255);
4965 by=vbound(by, 0, 176);
4966 int32_t fx=vbound(bx, 0, 255);
4967 int32_t fy=vbound(by, 0, 176);
4968
4969 int32_t cid = MAPCOMBO(bx,by);
4970
4971 //find out which combo row/column the coordinates are in
4972 bx &= 0xF0;
4973 by &= 0xF0;
4974
4975 int32_t type = COMBOTYPE(bx,by);
4976 int32_t type2 = FFCOMBOTYPE(fx,fy);
4977 int32_t flag = MAPFLAG(bx,by);
4978 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4979 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4980 int32_t i = (bx>>4) + by;
4981
4982 if(i > 175)
4983 {
4984 al_trace("check_slash_block(weapon *w): %s\n", "i > 175");
4985 return;
4986 }
4987
4988 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4989 type = cNONE;
4990 bool ignorescreen=false;
4991 bool ignoreffc=false;
4992
4993 if(get_bit(screengrid, i) != 0)
4994 {
4995 ignorescreen = true;
4996 }
4997
4998 int32_t current_ffcombo = getFFCAt(fx,fy);
4999
5000 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5001 {
5002 ignoreffc = true;
5003 }
5004 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
5005 type2 = cNONE;
5006 if(!isCuttableType(type) &&
5007 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
5008 {
5009 ignorescreen = true;
5010 }
5011
5012 if(!isCuttableType(type2) &&
5013 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
5014 {
5015 ignoreffc = true;
5016 }
5017
5018 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5019
5020 int32_t sworditem = (par_item >-1 ? itemsbuf[par_item].fam_type : current_item(itype_sword)); //Get the level of the item, else the highest sword level in inventory.
5021
5022 if(!ignorescreen)
5023 {
5024 if((flag >= 16)&&(flag <= 31))
5025 {
5026 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5027 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5028 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5029 }
5030 else if(flag == mfARMOS_SECRET)
5031 {
5032 s->data[i] = s->secretcombo[sSTAIRS];
5033 s->cset[i] = s->secretcset[sSTAIRS];
5034 s->sflag[i] = s->secretflag[sSTAIRS];
5035 sfx(tmpscr->secretsfx);
5036 }
5037 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
5038 {
5039 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5040 {
5041 findentrance(bx,by,mfSWORD+i2,true);
5042 }
5043
5044 findentrance(bx,by,mfSTRIKE,true);
5045 }
5046 else if(((flag2 >= 16)&&(flag2 <= 31)))
5047 {
5048 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5049 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5050 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5051 }
5052 else if(flag2 == mfARMOS_SECRET)
5053 {
5054 s->data[i] = s->secretcombo[sSTAIRS];
5055 s->cset[i] = s->secretcset[sSTAIRS];
5056 s->sflag[i] = s->secretflag[sSTAIRS];
5057 sfx(tmpscr->secretsfx);
5058 }
5059 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
5060 {
5061 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5062 {
5063 findentrance(bx,by,mfSWORD+i2,true);
5064 }
5065
5066 findentrance(bx,by,mfSTRIKE,true);
5067 }
5068 else
5069 {
5070 if(isCuttableNextType(type))
5071 {
5072 s->data[i]++;
5073 }
5074 else
5075 {
5076 s->data[i] = s->undercombo;
5077 s->cset[i] = s->undercset;
5078 s->sflag[i] = 0;
5079 }
5080
5081 //pausenow=true;
5082 }
5083 }
5084
5085 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
5086 {
5087 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5088 {
5089 findentrance(bx,by,mfSWORD+i2,true);
5090 }
5091
5092 findentrance(fx,fy,mfSTRIKE,true);
5093 }
5094 else if(!ignoreffc)
5095 {
5096 if(isCuttableNextType(type2))
5097 {
5098 s->ffcs[current_ffcombo].incData(1);
5099 }
5100 else
5101 {
5102 s->ffcs[current_ffcombo].setData(s->undercombo);
5103 s->ffcs[current_ffcombo].cset = s->undercset;
5104 }
5105 }
5106
5107 if(!ignorescreen)
5108 {
5109 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
5110
5111 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5112 {
5113 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5114 sfx(tmpscr->secretsfx);
5115 }
5116 else if(isCuttableItemType(type))
5117 {
5118 int32_t it = -1;
5119 int32_t thedropset = -1;
5120 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
5121 {
5122 if ( combobuf[cid].usrflags&cflag11 )
5123 {
5124 it = combobuf[cid].attribytes[1];
5125 }
5126 else
5127 {
5128 it = select_dropitem(combobuf[cid].attribytes[1]);
5129 thedropset = combobuf[cid].attribytes[1];
5130 }
5131 }
5132 else
5133 {
5134 it = select_dropitem(12);
5135 thedropset = 12;
5136 }
5137
5138 if(it!=-1)
5139 {
5140 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5141 itm->from_dropset = thedropset;
5142 items.add(itm);
5143 }
5144 }
5145
5146 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5147
5148 if(get_bit(quest_rules,qr_MORESOUNDS))
5149 {
5150 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
5151 {
5152 if (combobuf[cid].usrflags&cflag3)
5153 {
5154 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5155 }
5156 }
5157 else
5158 {
5159 if (combobuf[cid].usrflags&cflag3)
5160 {
5161 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5162 }
5163 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5164 }
5165 }
5166
5167 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5168 if(decotype > 3) decotype = 0;
5169 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5170 switch(decotype)
5171 {
5172 case -2: break; //nothing
5173 case -1:
5174 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
5175 break;
5176 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5177 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5178 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5179 }
5180 }
5181
5182 if(!ignoreffc)
5183 {
5184 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
5185
5186 if(isCuttableItemType(type2))
5187 {
5188 int32_t it=-1;
5189 int32_t thedropset = -1;
5190 if ( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) )
5191 {
5192 if(combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag11)
5193 it = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5194 else
5195 {
5196 thedropset = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5197 it = select_dropitem(thedropset);
5198 }
5199 }
5200 else
5201 {
5202 it = select_dropitem(12);
5203 thedropset = 12;
5204 }
5205
5206 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
5207 {
5208 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5209 itm->from_dropset = thedropset;
5210 items.add(itm);
5211 }
5212 }
5213
5214 if(get_bit(quest_rules,qr_MORESOUNDS))
5215 {
5216 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
5217 {
5218 if (combobuf[cid].usrflags&cflag3)
5219 {
5220 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5221 }
5222 }
5223 else
5224 {
5225 if (combobuf[cid].usrflags&cflag3)
5226 {
5227 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5228 }
5229 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5230 }
5231 }
5232
5233 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5234 if(decotype > 3) decotype = 0;
5235 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5236 switch(decotype)
5237 {
5238 case -2: break; //nothing
5239 case -1:
5240 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
5241 break;
5242 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5243 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5244 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5245 }
5246 }
5247 }
5248
5249 //TODO: Boomerang that cuts bushes. -L
5250 /*void HeroClass::slash_bush()
5251 {
5252
5253 }*/
5254
5255 24382 void HeroClass::check_wand_block(int32_t bx, int32_t by)
5256 {
5257 //keep things inside the screen boundaries
5258 24382 bx=vbound(bx, 0, 255);
5259 24382 by=vbound(by, 0, 176);
5260 24382 int32_t fx=vbound(bx, 0, 255);
5261 24382 int32_t fy=vbound(by, 0, 176);
5262 24382 int32_t cid = MAPCOMBO(bx,by);
5263
5264 //first things first
5265
2/4
✓ Branch 0 taken 24382 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24382 times.
24382 if(z>8||fakez>8) return;
5266
5267 //find out which combo row/column the coordinates are in
5268 24382 bx &= 0xF0;
5269 24382 by &= 0xF0;
5270
5271 24382 int32_t flag = MAPFLAG(bx,by);
5272 24382 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5273 24382 int32_t flag3=0;
5274 24382 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5275 24382 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5276 24382 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5277 24382 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5278
5279
4/8
✓ Branch 0 taken 24382 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24382 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24382 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 24382 times.
24382 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5280 flag3=mfWAND;
5281
5282
4/8
✓ Branch 0 taken 24382 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24382 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24382 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 24382 times.
24382 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5283 flag3=mfSTRIKE;
5284
5285 24382 int32_t i = (bx>>4) + by;
5286
5287
6/12
✓ Branch 0 taken 24382 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24382 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24382 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 24382 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 24382 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 24382 times.
✗ Branch 11 not taken.
24382 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5288 24382 return;
5289
5290 if(i > 175)
5291 return;
5292
5293 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5294
5295 //findentrance(bx,by,mfWAND,true);
5296 //findentrance(bx,by,mfSTRIKE,true);
5297 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5298 {
5299 if(flag3==mfWAND||flag3==mfSTRIKE)
5300 {
5301 findentrance(fx,fy,mfWAND,true);
5302 findentrance(fx,fy,mfSTRIKE,true);
5303 }
5304 }
5305
5306 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5307 24382 }
5308
5309 180 void HeroClass::check_pound_block(int32_t bx, int32_t by)
5310 {
5311 //keep things inside the screen boundaries
5312 180 bx=vbound(bx, 0, 255);
5313 180 by=vbound(by, 0, 176);
5314 180 int32_t fx=vbound(bx, 0, 255);
5315 180 int32_t fy=vbound(by, 0, 176);
5316 180 int32_t cid = MAPCOMBO(bx,by);
5317
5318 //first things first
5319
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 180 times.
180 if(z>8||fakez>8) return;
5320
5321 //find out which combo row/column the coordinates are in
5322 180 bx &= 0xF0;
5323 180 by &= 0xF0;
5324
5325 180 int32_t type = COMBOTYPE(bx,by);
5326 180 int32_t type2 = FFCOMBOTYPE(fx,fy);
5327 180 int32_t flag = MAPFLAG(bx,by);
5328 180 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5329 180 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5330 180 int32_t i = (bx>>4) + by;
5331
5332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if(i > 175)
5333 return;
5334
5335 180 bool ignorescreen=false;
5336 180 bool ignoreffc=false;
5337 180 bool pound=false;
5338
5339
6/10
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 152 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 152 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 152 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 152 times.
180 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5340 152 ignorescreen = true; // Affect only FFCs
5341
5342
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 13 times.
180 if(get_bit(screengrid, i) != 0)
5343 13 ignorescreen = true;
5344
5345 180 int32_t current_ffcombo = getFFCAt(fx,fy);
5346
5347
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5348 180 ignoreffc = true;
5349
5350
3/6
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 180 times.
180 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
5351 180 ignoreffc = true;
5352
5353
3/4
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
180 if(ignorescreen && ignoreffc) // Nothing to do.
5354 160 return;
5355
5356 20 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5357
5358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(!ignorescreen)
5359 {
5360
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20 times.
20 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5361 {
5362 findentrance(bx,by,mfHAMMER,true);
5363 findentrance(bx,by,mfSTRIKE,true);
5364 }
5365
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20 times.
20 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5366 {
5367 findentrance(bx,by,mfHAMMER,true);
5368 findentrance(bx,by,mfSTRIKE,true);
5369 }
5370
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20 else if((flag >= 16)&&(flag <= 31))
5371 {
5372 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5373 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5374 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5375 }
5376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 else if(flag == mfARMOS_SECRET)
5377 {
5378 s->data[i] = s->secretcombo[sSTAIRS];
5379 s->cset[i] = s->secretcset[sSTAIRS];
5380 s->sflag[i] = s->secretflag[sSTAIRS];
5381 sfx(tmpscr->secretsfx);
5382 }
5383
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20 else if((flag2 >= 16)&&(flag2 <= 31))
5384 {
5385 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5386 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5387 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5388 }
5389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 else if(flag2 == mfARMOS_SECRET)
5390 {
5391 s->data[i] = s->secretcombo[sSTAIRS];
5392 s->cset[i] = s->secretcset[sSTAIRS];
5393 s->sflag[i] = s->secretflag[sSTAIRS];
5394 sfx(tmpscr->secretsfx);
5395 }
5396 20 else pound = true;
5397 20 }
5398
5399
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(!ignoreffc)
5400 {
5401 if(flag3==mfHAMMER||flag3==mfSTRIKE)
5402 {
5403 findentrance(fx,fy,mfHAMMER,true);
5404 findentrance(fx,fy,mfSTRIKE,true);
5405 }
5406 else
5407 {
5408 s->ffcs[current_ffcombo].incData(1);
5409 }
5410 }
5411
5412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(!ignorescreen)
5413 {
5414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(pound)
5415 20 s->data[i]+=1;
5416
5417 20 set_bit(screengrid,i,1);
5418
5419
2/8
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
20 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5420 {
5421 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5422 sfx(tmpscr->secretsfx);
5423 }
5424
5425
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5426 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5427
5428 20 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5429 20 }
5430
5431
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(!ignoreffc)
5432 {
5433 set_bit(ffcgrid,current_ffcombo,1);
5434
5435 if(type2==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5436 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5437 }
5438
5439 20 return;
5440 180 }
5441
5442
5443 void HeroClass::check_wand_block(weapon *w)
5444 {
5445
5446 int32_t par_item = w->parentitem;
5447 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
5448 int32_t usewpn = -1;
5449 if ( par_item > -1 )
5450 {
5451 usewpn = itemsbuf[par_item].useweapon;
5452 }
5453 else if ( par_item == -1 && w->ScriptGenerated )
5454 {
5455 usewpn = w->useweapon;
5456 }
5457 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
5458 if(usewpn != wWand) return;
5459
5460
5461 int32_t bx = 0, by = 0;
5462 bx = ((int32_t)w->x) + (((int32_t)w->hxsz)/2);
5463 by = ((int32_t)w->y) + (((int32_t)w->hysz)/2);
5464
5465 //keep things inside the screen boundaries
5466 bx=vbound(bx, 0, 255);
5467 by=vbound(by, 0, 176);
5468 int32_t fx=vbound(bx, 0, 255);
5469 int32_t fy=vbound(by, 0, 176);
5470 int32_t cid = MAPCOMBO(bx,by);
5471 //first things first
5472 if(z>8||fakez>8) return;
5473
5474 //find out which combo row/column the coordinates are in
5475 bx &= 0xF0;
5476 by &= 0xF0;
5477
5478 int32_t flag = MAPFLAG(bx,by);
5479 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5480 int32_t flag3=0;
5481 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5482 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5483 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5484 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5485
5486 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5487 flag3=mfWAND;
5488
5489 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5490 flag3=mfSTRIKE;
5491
5492 int32_t i = (bx>>4) + by;
5493
5494 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5495 return;
5496
5497 if(i > 175)
5498 return;
5499
5500 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5501
5502 //findentrance(bx,by,mfWAND,true);
5503 //findentrance(bx,by,mfSTRIKE,true);
5504 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5505 {
5506 if(flag3==mfWAND||flag3==mfSTRIKE)
5507 {
5508 findentrance(fx,fy,mfWAND,true);
5509 findentrance(fx,fy,mfSTRIKE,true);
5510 }
5511 }
5512
5513 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5514 }
5515
5516 void HeroClass::check_pound_block(weapon *w)
5517 {
5518
5519 int32_t par_item = w->parentitem;
5520 al_trace("check_pound_block(weapon *w): par_item is: %d\n", par_item);
5521 int32_t usewpn = -1;
5522 if ( par_item > -1 )
5523 {
5524 usewpn = itemsbuf[par_item].useweapon;
5525 }
5526 else if ( par_item == -1 && w->ScriptGenerated )
5527 {
5528 usewpn = w->useweapon;
5529 }
5530 al_trace("check_pound_block(weapon *w): usewpn is: %d\n", usewpn);
5531 if(usewpn != wHammer) return;
5532
5533
5534 int32_t bx = 0, by = 0;
5535 bx = ((int32_t)w->x) + (((int32_t)w->hxsz)/2);
5536 by = ((int32_t)w->y) + (((int32_t)w->hysz)/2);
5537 //keep things inside the screen boundaries
5538 bx=vbound(bx, 0, 255);
5539 by=vbound(by, 0, 176);
5540 int32_t fx=vbound(bx, 0, 255);
5541 int32_t fy=vbound(by, 0, 176);
5542 int32_t cid = MAPCOMBO(bx,by);
5543 //first things first
5544 if(z>8||fakez>8) return;
5545
5546 //find out which combo row/column the coordinates are in
5547 bx &= 0xF0;
5548 by &= 0xF0;
5549
5550 int32_t type = COMBOTYPE(bx,by);
5551 int32_t type2 = FFCOMBOTYPE(fx,fy);
5552 int32_t flag = MAPFLAG(bx,by);
5553 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5554 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5555 int32_t i = (bx>>4) + by;
5556
5557 if(i > 175)
5558 return;
5559
5560 bool ignorescreen=false;
5561 bool ignoreffc=false;
5562 bool pound=false;
5563
5564 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5565 ignorescreen = true; // Affect only FFCs
5566
5567 if(get_bit(screengrid, i) != 0)
5568 ignorescreen = true;
5569
5570 int32_t current_ffcombo = getFFCAt(fx,fy);
5571
5572 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5573 ignoreffc = true;
5574
5575 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
5576 ignoreffc = true;
5577
5578 if(ignorescreen && ignoreffc) // Nothing to do.
5579 return;
5580
5581 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5582
5583 if(!ignorescreen)
5584 {
5585 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5586 {
5587 findentrance(bx,by,mfHAMMER,true);
5588 findentrance(bx,by,mfSTRIKE,true);
5589 }
5590 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5591 {
5592 findentrance(bx,by,mfHAMMER,true);
5593 findentrance(bx,by,mfSTRIKE,true);
5594 }
5595 else if((flag >= 16)&&(flag <= 31))
5596 {
5597 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5598 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5599 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5600 }
5601 else if(flag == mfARMOS_SECRET)
5602 {
5603 s->data[i] = s->secretcombo[sSTAIRS];
5604 s->cset[i] = s->secretcset[sSTAIRS];
5605 s->sflag[i] = s->secretflag[sSTAIRS];
5606 sfx(tmpscr->secretsfx);
5607 }
5608 else if((flag2 >= 16)&&(flag2 <= 31))
5609 {
5610 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5611 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5612 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5613 }
5614 else if(flag2 == mfARMOS_SECRET)
5615 {
5616 s->data[i] = s->secretcombo[sSTAIRS];
5617 s->cset[i] = s->secretcset[sSTAIRS];
5618 s->sflag[i] = s->secretflag[sSTAIRS];
5619 sfx(tmpscr->secretsfx);
5620 }
5621 else pound = true;
5622 }
5623
5624 if(!ignoreffc)
5625 {
5626 if(flag3==mfHAMMER||flag3==mfSTRIKE)
5627 {
5628 findentrance(fx,fy,mfHAMMER,true);
5629 findentrance(fx,fy,mfSTRIKE,true);
5630 }
5631 else
5632 {
5633 s->ffcs[current_ffcombo].incData(1);
5634 }
5635 }
5636
5637 if(!ignorescreen)
5638 {
5639 if(pound)
5640 s->data[i]+=1;
5641
5642 set_bit(screengrid,i,1);
5643
5644 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5645 {
5646 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5647 sfx(tmpscr->secretsfx);
5648 }
5649
5650 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5651 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5652
5653 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5654 }
5655
5656 if(!ignoreffc)
5657 {
5658 set_bit(ffcgrid,current_ffcombo,1);
5659
5660 if(type2==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5661 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5662 }
5663
5664 return;
5665 }
5666
5667 //defend results should match defence types.
5668 //RETURN VALUES:
5669 // -1 iGNORE WEAPON
5670 // 0 No effects
5671 // 1 Effects, weapon is not ignored or removed
5672 4331 int32_t HeroClass::defend(weapon *w)
5673 {
5674 4331 int32_t def = conv_edef_unblockable(defence[w->id], w->unblockable);
5675
1/25
✓ Branch 0 taken 4331 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
4331 switch(def)
5676 {
5677 4331 case edNORMAL: return 1;
5678 case edHALFDAMAGE: // : IMPLEMENTED : Take half damage
5679 {
5680 w->power *= 0.5;
5681 return 1;
5682 }
5683 case edQUARTDAMAGE:
5684 {
5685 w->power *= 0.25;
5686 return 1;
5687 }
5688 case edSTUNONLY:
5689 {
5690 setStunClock(120);
5691 return 1;
5692 }
5693 case edSTUNORCHINK: // : IMPLEMENTED : If damage > 0, stun instead. Else, bounce off.
5694 {
5695 if (w->power > 0)
5696 {
5697 setStunClock(120);
5698 return 1;
5699 }
5700 else
5701 {
5702 sfx(WAV_CHINK,pan(int32_t(x)));
5703 w->dead = 0;
5704 return -1;
5705 }
5706 }
5707 case edSTUNORIGNORE: // : IMPLEMENTED : If damage > 0, stun instead. Else, ignore.
5708 {
5709 if (w->power > 0)
5710 {
5711 setStunClock(120);
5712 return 1;
5713 }
5714 else
5715 {
5716 return -1;
5717 }
5718 }
5719 case edCHINKL1: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5720 {
5721 if (w->power < 1)
5722 {
5723 sfx(WAV_CHINK,pan(int32_t(x)));
5724 w->dead = 0;
5725 return -1;
5726 }
5727 else
5728 {
5729 return 1;
5730 }
5731 }
5732 case edCHINKL2: // : IMPLEMENTED : Bounce off unless damage >= 2
5733 {
5734 if (w->power < 2)
5735 {
5736 sfx(WAV_CHINK,pan(int32_t(x)));
5737 w->dead = 0;
5738 return -1;
5739 }
5740 else
5741 {
5742 return 1;
5743 }
5744 }
5745 case edCHINKL4: //: IMPLEMENTED : Bounce off unless damage >= 4
5746 {
5747 if (w->power < 4)
5748 {
5749 sfx(WAV_CHINK,pan(int32_t(x)));
5750 w->dead = 0;
5751 return -1;
5752 }
5753 else
5754 {
5755 return 1;
5756 }
5757 }
5758 case edCHINKL6: // : IMPLEMENTED : Bounce off unless damage >= 6
5759 {
5760 if (w->power < 6)
5761 {
5762 sfx(WAV_CHINK,pan(int32_t(x)));
5763 w->dead = 0;
5764 return -1;
5765 }
5766 else
5767 {
5768 return 1;
5769 }
5770 }
5771 case edCHINKL8: // : IMPLEMENTED : Bounce off unless damage >= 8
5772 {
5773 if (w->power < 8)
5774 {
5775 sfx(WAV_CHINK,pan(int32_t(x)));
5776 w->dead = 0;
5777 return -1;
5778 }
5779 else
5780 {
5781 return 1;
5782 }
5783 }
5784 case edCHINK: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5785 {
5786 sfx(WAV_CHINK,pan(int32_t(x)));
5787 w->dead = 0;
5788 return -1;
5789 }
5790 case edIGNOREL1: // : IMPLEMENTED : Ignore unless damage > 1.
5791 {
5792 if (w->power < 1)
5793 {
5794 return -1;
5795 }
5796 else return 1;
5797 }
5798 case edIGNORE: // : IMPLEMENTED : Do Nothing
5799 {
5800 return -1;
5801 }
5802 case ed1HKO: // : IMPLEMENTED : One-hit knock-out
5803 {
5804 game->set_life(0);
5805 return 1;
5806 }
5807 case edCHINKL10: //: IMPLEMENTED : If damage is less than 10
5808 {
5809 if (w->power < 10)
5810 {
5811 sfx(WAV_CHINK,pan(int32_t(x)));
5812 w->dead = 0;
5813 return -1;
5814 }
5815 else
5816 {
5817 return 1;
5818 }
5819 }
5820 case ed2x: // : IMPLEMENTED : Double damage.
5821 {
5822 w->power *= 2;
5823 return 1;
5824 }
5825 case ed3x: // : IMPLEMENTED : Triple Damage.
5826 {
5827 w->power *= 3;
5828 return 1;
5829 }
5830 case ed4x: // : IMPLEMENTED : 4x damage.
5831 {
5832 w->power *= 4;
5833 return 1;
5834 }
5835 case edHEAL: // : IMPLEMENTED : Gain the weapon damage in HP.
5836 {
5837 //sfx(WAV_HEAL,pan(int32_t(x)));
5838 game->set_life(zc_min(game->get_life()+w->power, game->get_maxlife()));
5839 w->dead = 0;
5840 return -1;
5841 }
5842
5843 case edFREEZE: return 1; //Not IMPLEMENTED
5844
5845 case edLEVELDAMAGE: //Damage * item level
5846 {
5847 w->power *= w->family_level;
5848 return 1;
5849 }
5850 case edLEVELREDUCTION: //Damage / item level
5851 {
5852 if ( w->family_level > 0 )
5853 {
5854 w->power /= w->family_level;
5855 }
5856 else w->power = 0;
5857 return 1;
5858 }
5859
5860 //edLEVELCHINK2, //If item level is < 2: This needs a weapon variable that is set by
5861 //edLEVELCHINK3, //If item level is < 3: the item that generates it (itemdata::level stored to
5862 //edLEVELCHINK4, //If item level is < 4: weapon::level, or something similar; then a check to
5863 //edLEVELCHINK5, //If item level is < 5: read weapon::level in hit detection.
5864
5865 //edSHOCK, //buzz blob
5866
5867
5868 case edBREAKSHIELD: //destroy the player's present shield
5869 {
5870 w->power = 0;
5871 w->dead = 0;
5872 int32_t itemid = getCurrentShield();
5873 //sfx(WAV_BREAKSHIELD,pan(int32_t(x)));
5874 if(itemsbuf[itemid].flags&ITEM_EDIBLE)
5875 game->set_item(itemid, false);
5876 //Remove Hero's shield
5877 return -1;
5878 }
5879
5880
5881
5882 default: return 0;
5883 }
5884 4331 }
5885
5886 4240 int32_t HeroClass::compareDir(int32_t other)
5887 {
5888
5/6
✓ Branch 0 taken 4235 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4235 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 4238 times.
4240 if(other != NORMAL_DIR(other))
5889 2 return 0; //*sigh* scripts expect dirs >=8 to NOT hit shields...
5890 4238 int32_t ret = 0;
5891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4238 times.
4238 auto d = (shield_forcedir < 0) ? dir : shield_forcedir;
5892
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 798 times.
✓ Branch 2 taken 714 times.
✓ Branch 3 taken 1393 times.
✓ Branch 4 taken 1333 times.
4238 switch(d)
5893 {
5894 case up:
5895 {
5896
3/3
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 318 times.
✓ Branch 2 taken 311 times.
798 switch(X_DIR(other))
5897 {
5898 case left:
5899 318 ret |= CMPDIR_RIGHT;
5900 318 break;
5901 case right:
5902 311 ret |= CMPDIR_LEFT;
5903 311 break;
5904 }
5905
3/3
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 174 times.
✓ Branch 2 taken 537 times.
798 switch(Y_DIR(other))
5906 {
5907 case up:
5908 174 ret |= CMPDIR_BACK;
5909 174 break;
5910 case down:
5911 537 ret |= CMPDIR_FRONT;
5912 537 break;
5913 }
5914 798 break;
5915 }
5916 case down:
5917 {
5918
3/3
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 233 times.
✓ Branch 2 taken 298 times.
714 switch(X_DIR(other))
5919 {
5920 case left:
5921 233 ret |= CMPDIR_LEFT;
5922 233 break;
5923 case right:
5924 298 ret |= CMPDIR_RIGHT;
5925 298 break;
5926 }
5927
3/3
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 494 times.
✓ Branch 2 taken 134 times.
714 switch(Y_DIR(other))
5928 {
5929 case up:
5930 494 ret |= CMPDIR_FRONT;
5931 494 break;
5932 case down:
5933 134 ret |= CMPDIR_BACK;
5934 134 break;
5935 }
5936 714 break;
5937 }
5938 case left:
5939 {
5940
3/3
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 212 times.
✓ Branch 2 taken 1125 times.
1393 switch(X_DIR(other))
5941 {
5942 case left:
5943 212 ret |= CMPDIR_BACK;
5944 212 break;
5945 case right:
5946 1125 ret |= CMPDIR_FRONT;
5947 1125 break;
5948 }
5949
3/3
✓ Branch 0 taken 492 times.
✓ Branch 1 taken 446 times.
✓ Branch 2 taken 455 times.
1393 switch(Y_DIR(other))
5950 {
5951 case up:
5952 446 ret |= CMPDIR_LEFT;
5953 446 break;
5954 case down:
5955 455 ret |= CMPDIR_RIGHT;
5956 455 break;
5957 }
5958 1393 break;
5959 }
5960 case right:
5961 {
5962
3/3
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1086 times.
✓ Branch 2 taken 193 times.
1333 switch(X_DIR(other))
5963 {
5964 case left:
5965 1086 ret |= CMPDIR_FRONT;
5966 1086 break;
5967 case right:
5968 193 ret |= CMPDIR_BACK;
5969 193 break;
5970 }
5971
3/3
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 364 times.
✓ Branch 2 taken 513 times.
1333 switch(Y_DIR(other))
5972 {
5973 case up:
5974 364 ret |= CMPDIR_RIGHT;
5975 364 break;
5976 case down:
5977 513 ret |= CMPDIR_LEFT;
5978 513 break;
5979 }
5980 1333 break;
5981 }
5982 }
5983 4238 return ret;
5984 4240 }
5985
5986 4240 bool compareShield(int32_t cmpdir, itemdata const& shield)
5987 {
5988
1/2
✓ Branch 0 taken 4240 times.
✗ Branch 1 not taken.
4240 bool standard = !(shield.flags&ITEM_FLAG9) || usingActiveShield();
5989
1/2
✓ Branch 0 taken 4240 times.
✗ Branch 1 not taken.
4240 if(standard) //Use standard sides, either a passive shield, or a held active shield
5990 {
5991
3/4
✓ Branch 0 taken 3242 times.
✓ Branch 1 taken 998 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3242 times.
4240 if((cmpdir&CMPDIR_FRONT) && (shield.flags&ITEM_FLAG1))
5992 3242 return true;
5993
3/4
✓ Branch 0 taken 713 times.
✓ Branch 1 taken 285 times.
✓ Branch 2 taken 713 times.
✗ Branch 3 not taken.
998 else if((cmpdir&CMPDIR_BACK) && (shield.flags&ITEM_FLAG2))
5994 return true;
5995
3/4
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 567 times.
✓ Branch 2 taken 431 times.
✗ Branch 3 not taken.
998 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&ITEM_FLAG3))
5996 return true;
5997
3/4
✓ Branch 0 taken 445 times.
✓ Branch 1 taken 553 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 445 times.
998 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&ITEM_FLAG4))
5998 return true;
5999 998 }
6000 else //Active Shield that is NOT held down
6001 {
6002 if((cmpdir&CMPDIR_FRONT) && (shield.flags&ITEM_FLAG5))
6003 return true;
6004 else if((cmpdir&CMPDIR_BACK) && (shield.flags&ITEM_FLAG6))
6005 return true;
6006 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&ITEM_FLAG7))
6007 return true;
6008 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&ITEM_FLAG8))
6009 return true;
6010 }
6011 998 return false;
6012 4240 }
6013
6014 3004289 int32_t HeroClass::EwpnHit()
6015 {
6016
2/2
✓ Branch 0 taken 3002323 times.
✓ Branch 1 taken 3226650 times.
6228973 for(int32_t i=0; i<Ewpns.Count(); i++)
6017 {
6018
2/2
✓ Branch 0 taken 3222319 times.
✓ Branch 1 taken 4331 times.
3226650 if(Ewpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6019 {
6020 4331 weapon *ew = (weapon*)(Ewpns.spr(i));
6021
6022
3/6
✓ Branch 0 taken 4331 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4331 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4331 times.
4331 if((ew->ignoreHero)==true || ew->fallclk|| ew->drownclk)
6023 break;
6024
6025 4331 int32_t stompid = current_item_id(itype_stompboots);
6026
6027
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 4331 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
4331 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
6028 ((z+fakez) > (ew->z+(ew->fakez))) ||
6029 ((isSideViewHero() && (y+16)-(ew->y)<=14) && falling_oldy<y)))
6030 {
6031 itemdata const& stomp = itemsbuf[stompid];
6032 bool remove = false;
6033 switch(ew->id)
6034 {
6035 case ewFireball2:
6036 case ewFireball:
6037 if(ew->type & 1) //Boss fireball
6038 {
6039 if(stomp.misc2 & (shFIREBALL2))
6040 remove = true;
6041 }
6042 else
6043 {
6044 if(stomp.misc2 & (shFIREBALL))
6045 remove = true;
6046 }
6047
6048 break;
6049
6050 case ewMagic:
6051 if((stomp.misc2 & shMAGIC))
6052 remove = true;
6053 break;
6054
6055 case ewSword:
6056 if((stomp.misc2 & shSWORD))
6057 remove = true;
6058
6059 break;
6060
6061 case ewFlame:
6062 if((stomp.misc2 & shFLAME))
6063 remove = true;
6064
6065 break;
6066
6067 case ewRock:
6068 if((stomp.misc2 & shROCK))
6069 remove = true;
6070
6071 break;
6072
6073 case ewArrow:
6074 if((stomp.misc2 & shARROW))
6075 remove = true;
6076
6077 break;
6078
6079 case ewBrang:
6080 if((stomp.misc2 & shBRANG))
6081 remove = true;
6082
6083 break;
6084
6085 default: // Just throw the script weapons in here...
6086 if(ew->id>=wScript1 && ew->id<=wScript10)
6087 {
6088 if((stomp.misc2 & shSCRIPT))
6089 remove = true;
6090 }
6091
6092 break;
6093 }
6094 if (remove)
6095 {
6096 ew->onhit(false);
6097 sfx(WAV_CHINK,pan(x.getInt()));
6098 continue;
6099 }
6100 }
6101
6102 4331 int32_t defresult = defend(ew);
6103
1/2
✓ Branch 0 taken 4331 times.
✗ Branch 1 not taken.
4331 if ( defresult == -1 ) return -1; //The weapon did something special, but it is otherwise ignored, possibly killed by defend().
6104
6105
2/2
✓ Branch 0 taken 4330 times.
✓ Branch 1 taken 1 times.
4331 if(ew->id==ewWind)
6106 {
6107 1 xofs=1000;
6108 1 action=freeze; FFCore.setHeroAction(freeze);
6109 1 ew->misc=999; // in enemy wind
6110 1 attackclk=0;
6111 1 return -1;
6112 }
6113
6114
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 4320 times.
4330 switch(ew->id)
6115 {
6116 case ewLitBomb:
6117 case ewBomb:
6118 case ewLitSBomb:
6119 case ewSBomb:
6120 10 return i;
6121 }
6122
6123 4320 int32_t itemid = getCurrentShield(false);
6124
4/6
✓ Branch 0 taken 4240 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 4240 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4240 times.
4320 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid))) return i;
6125 4240 itemdata const& shield = itemsbuf[itemid];
6126 4240 auto cmpdir = compareDir(ew->dir);
6127 4240 bool hitshield = compareShield(cmpdir, shield);
6128
6129
6130
12/18
✓ Branch 0 taken 3242 times.
✓ Branch 1 taken 998 times.
✓ Branch 2 taken 2598 times.
✓ Branch 3 taken 644 times.
✓ Branch 4 taken 2598 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2591 times.
✓ Branch 7 taken 7 times.
✓ Branch 8 taken 2591 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2591 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2591 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2591 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 2591 times.
4240 if(!hitshield || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF)
6131 {
6132 1649 return i;
6133 }
6134
6135 2591 paymagiccost(itemid);
6136
6137 2591 bool reflect = false;
6138
6139
7/8
✓ Branch 0 taken 1599 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 343 times.
✓ Branch 3 taken 199 times.
✓ Branch 4 taken 79 times.
✓ Branch 5 taken 140 times.
✓ Branch 6 taken 112 times.
✓ Branch 7 taken 119 times.
2591 switch(ew->id)
6140 {
6141 case ewFireball2:
6142 case ewFireball:
6143
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 1484 times.
1599 if(ew->type & 1) //Boss fireball
6144 {
6145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(!(shield.misc1 & (shFIREBALL2)))
6146 115 return i;
6147
6148 reflect = ((shield.misc2 & shFIREBALL2) != 0);
6149 }
6150 else
6151 {
6152
2/2
✓ Branch 0 taken 1435 times.
✓ Branch 1 taken 49 times.
1484 if(!(shield.misc1 & (shFIREBALL)))
6153 49 return i;
6154
6155 1435 reflect = ((shield.misc2 & shFIREBALL) != 0);
6156 }
6157
6158 1435 break;
6159
6160 case ewMagic:
6161
2/2
✓ Branch 0 taken 335 times.
✓ Branch 1 taken 8 times.
343 if(!(shield.misc1 & shMAGIC))
6162 8 return i;
6163
6164 335 reflect = ((shield.misc2 & shMAGIC) != 0);
6165 335 break;
6166
6167 case ewSword:
6168
2/2
✓ Branch 0 taken 191 times.
✓ Branch 1 taken 8 times.
199 if(!(shield.misc1 & shSWORD))
6169 8 return i;
6170
6171 191 reflect = ((shield.misc2 & shSWORD) != 0);
6172 191 break;
6173
6174 case ewFlame:
6175
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 46 times.
79 if(!(shield.misc1 & shFLAME))
6176 46 return i;
6177
6178 33 reflect = ((shield.misc2 & shFLAME) != 0); // Actually isn't reflected.
6179 33 break;
6180
6181 case ewRock:
6182
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!(shield.misc1 & shROCK))
6183 return i;
6184
6185 140 reflect = (shield.misc2 & shROCK);
6186 140 break;
6187
6188 case ewArrow:
6189
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!(shield.misc1 & shARROW))
6190 return i;
6191
6192 112 reflect = ((shield.misc2 & shARROW) != 0); // Actually isn't reflected.
6193 112 break;
6194
6195 case ewBrang:
6196
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if(!(shield.misc1 & shBRANG))
6197 return i;
6198
6199 119 break;
6200
6201 default: // Just throw the script weapons in here...
6202 if(ew->id>=wScript1 && ew->id<=wScript10)
6203 {
6204 if(!(shield.misc1 & shSCRIPT))
6205 return i;
6206
6207 reflect = ((shield.misc2 & shSCRIPT) != 0);
6208 }
6209
6210 break;
6211 }
6212
6213
3/4
✓ Branch 0 taken 484 times.
✓ Branch 1 taken 1881 times.
✓ Branch 2 taken 484 times.
✗ Branch 3 not taken.
2365 if(reflect && (ew->unblockable&WPNUNB_REFL))
6214 reflect = false;
6215
3/4
✓ Branch 0 taken 1881 times.
✓ Branch 1 taken 484 times.
✓ Branch 2 taken 1881 times.
✗ Branch 3 not taken.
2365 if(!reflect && (ew->unblockable&WPNUNB_SHLD))
6216 return i;
6217
6218 2365 int32_t oldid = ew->id;
6219 2365 ew->onhit(false, reflect ? 2 : 1, dir);
6220
6221
2/2
✓ Branch 0 taken 1881 times.
✓ Branch 1 taken 484 times.
2365 if(ew->id != oldid) // changed type from ewX to wX
6222 {
6223 // ew->power*=game->get_hero_dmgmult();
6224 484 Lwpns.add(ew);
6225 484 Ewpns.remove(ew);
6226 484 ew->isLWeapon = true; //Make sure this gets set everywhere!
6227 484 }
6228
6229
2/2
✓ Branch 0 taken 2177 times.
✓ Branch 1 taken 188 times.
2365 if(ew->id==wRefMagic)
6230 {
6231 188 ew->ignoreHero=true;
6232 188 ew->ignorecombo=-1;
6233 188 }
6234
6235 2365 sfx(shield.usesound,pan(x.getInt()));
6236 2365 }
6237 3224684 }
6238
6239 3002323 return -1;
6240 3004289 }
6241
6242 3004289 int32_t HeroClass::LwpnHit() //only here to check magic hits
6243 {
6244
2/2
✓ Branch 0 taken 2932219 times.
✓ Branch 1 taken 1582994 times.
4515213 for(int32_t i=0; i<Lwpns.Count(); i++)
6245
2/2
✓ Branch 0 taken 1510924 times.
✓ Branch 1 taken 72070 times.
1582994 if(Lwpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6246 {
6247 72070 weapon *lw = (weapon*)(Lwpns.spr(i));
6248
6249
2/2
✓ Branch 0 taken 70650 times.
✓ Branch 1 taken 1420 times.
72070 if((lw->ignoreHero)==true)
6250 1420 break;
6251
6252
4/8
✓ Branch 0 taken 70650 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 70650 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70650 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 70650 times.
70650 if (!(lw->id == wRefFireball || lw->id == wRefMagic || lw->id == wRefBeam || lw->id == wRefRock)) return -1;
6253 int32_t itemid = getCurrentShield(false);
6254 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid))) return i;
6255 itemdata const& shield = itemsbuf[itemid];
6256 auto cmpdir = compareDir(lw->dir);
6257 bool hitshield = compareShield(cmpdir, shield);
6258 bool reflect = false;
6259
6260 switch(lw->id)
6261 {
6262 case wRefFireball:
6263 if(itemid<0)
6264 return i;
6265
6266 if(lw->type & 1) //Boss fireball
6267 return i;
6268
6269 if(!(shield.misc1 & (shFIREBALL)))
6270 return i;
6271
6272 reflect = ((shield.misc2 & shFIREBALL) != 0);
6273 break;
6274
6275 case wRefMagic:
6276 if(itemid<0)
6277 return i;
6278
6279 if(!(shield.misc1 & shMAGIC))
6280 return i;
6281
6282 reflect = ((shield.misc2 & shMAGIC) != 0);
6283 break;
6284
6285 case wRefBeam:
6286 if(itemid<0)
6287 return i;
6288
6289 if(!(shield.misc1 & shSWORD))
6290 return i;
6291
6292 reflect = ((shield.misc2 & shSWORD) != 0);
6293 break;
6294
6295 case wRefRock:
6296 if(itemid<0)
6297 return i;
6298
6299 if(!(shield.misc1 & shROCK))
6300 return i;
6301
6302 reflect = (shield.misc2 & shROCK);
6303 break;
6304
6305 default:
6306 return -1;
6307 }
6308
6309 if(!hitshield || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || hopclk==0xFF)
6310 return i;
6311
6312 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid))) return i;
6313
6314 paymagiccost(itemid);
6315
6316 lw->onhit(false, 1+reflect, dir);
6317 lw->ignoreHero=true;
6318 lw->ignorecombo=-1;
6319 sfx(shield.usesound,pan(x.getInt()));
6320 }
6321
6322 2933639 return -1;
6323 3004289 }
6324
6325 5988231 void HeroClass::checkhit()
6326 {
6327
2/2
✓ Branch 0 taken 2593000 times.
✓ Branch 1 taken 3395231 times.
5988231 if(checkhero==true)
6328 {
6329
2/2
✓ Branch 0 taken 204408 times.
✓ Branch 1 taken 3190823 times.
3395231 if(hclk>0)
6330 {
6331 204408 --hclk;
6332 204408 }
6333
6334
1/2
✓ Branch 0 taken 3395231 times.
✗ Branch 1 not taken.
3395231 if(NayrusLoveShieldClk>0)
6335 {
6336 --NayrusLoveShieldClk;
6337
6338 if(NayrusLoveShieldClk == 0 && nayruitem != -1)
6339 {
6340 stop_sfx(itemsbuf[nayruitem].usesound);
6341 stop_sfx(itemsbuf[nayruitem].usesound+1);
6342 nayruitem = -1;
6343 }
6344 else if(get_bit(quest_rules,qr_MORESOUNDS) && !(NayrusLoveShieldClk&0xF00) && nayruitem != -1)
6345 {
6346 stop_sfx(itemsbuf[nayruitem].usesound);
6347 cont_sfx(itemsbuf[nayruitem].usesound+1);
6348 }
6349 }
6350 3395231 }
6351
6352
4/4
✓ Branch 0 taken 3356567 times.
✓ Branch 1 taken 2631664 times.
✓ Branch 2 taken 3354099 times.
✓ Branch 3 taken 2468 times.
5988231 if(hclk<39 && action==gothit)
6353 {
6354 2468 action=none; FFCore.setHeroAction(none);
6355 2468 }
6356
6357
5/6
✓ Branch 0 taken 3356567 times.
✓ Branch 1 taken 2631664 times.
✓ Branch 2 taken 3356549 times.
✓ Branch 3 taken 18 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3356549 times.
5988231 if(hclk<39 && (action==swimhit || action == sideswimhit))
6358 {
6359 18 SetSwim();
6360 18 }
6361
6362
4/4
✓ Branch 0 taken 34378 times.
✓ Branch 1 taken 5953853 times.
✓ Branch 2 taken 8114 times.
✓ Branch 3 taken 26264 times.
5988231 if(hclk>=40 && action==gothit)
6363 {
6364 26264 int val = check_pitslide();
6365
4/4
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 26045 times.
✓ Branch 2 taken 26344 times.
✓ Branch 3 taken 26125 times.
26264 if(((ladderx+laddery) && ((hitdir&2)==ladderdir))||(!(ladderx+laddery)))
6366 {
6367
2/2
✓ Branch 0 taken 105376 times.
✓ Branch 1 taken 26344 times.
131720 for(int32_t i=0; i<4; i++)
6368 {
6369
5/5
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 21828 times.
✓ Branch 2 taken 26052 times.
✓ Branch 3 taken 27416 times.
✓ Branch 4 taken 29984 times.
105376 switch(hitdir)
6370 {
6371 case up:
6372
6/6
✓ Branch 0 taken 1364 times.
✓ Branch 1 taken 20464 times.
✓ Branch 2 taken 1018 times.
✓ Branch 3 taken 19446 times.
✓ Branch 4 taken 1371 times.
✓ Branch 5 taken 20457 times.
21828 if(hit_walkflag(x,y+(bigHitbox?-1:7),2)||(x.getInt()&7?hit_walkflag(x+16,y+(bigHitbox?-1:7),1):0))
6373 {
6374 1371 action=none; FFCore.setHeroAction(none);
6375 1371 }
6376
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 20453 times.
20457 else if (val == -1) --y;
6377
6378 21828 break;
6379
6380 case down:
6381
6/6
✓ Branch 0 taken 2039 times.
✓ Branch 1 taken 24013 times.
✓ Branch 2 taken 1696 times.
✓ Branch 3 taken 22317 times.
✓ Branch 4 taken 2055 times.
✓ Branch 5 taken 23997 times.
26052 if(hit_walkflag(x,y+16,2)||(x.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6382 {
6383 2055 action=none; FFCore.setHeroAction(none);
6384 2055 }
6385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23997 times.
23997 else if (val == -1) ++y;
6386
6387 26052 break;
6388
6389 case left:
6390
7/8
✓ Branch 0 taken 26563 times.
✓ Branch 1 taken 853 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26563 times.
✓ Branch 4 taken 622 times.
✓ Branch 5 taken 25941 times.
✓ Branch 6 taken 853 times.
✓ Branch 7 taken 26563 times.
27416 if(hit_walkflag(x-1,y+(bigHitbox?0:8),1)||hit_walkflag(x-1,y+8,1)||(y.getInt()&7?hit_walkflag(x-1,y+16,1):0))
6391 {
6392 853 action=none; FFCore.setHeroAction(none);
6393 853 }
6394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26563 times.
26563 else if (val == -1) --x;
6395
6396 27416 break;
6397
6398 case right:
6399
7/8
✓ Branch 0 taken 28909 times.
✓ Branch 1 taken 1075 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28909 times.
✓ Branch 4 taken 28492 times.
✓ Branch 5 taken 417 times.
✓ Branch 6 taken 1079 times.
✓ Branch 7 taken 28905 times.
29984 if(hit_walkflag(x+16,y+(bigHitbox?0:8),1)||hit_walkflag(x+16,y+8,1)||(y.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6400 {
6401 1079 action=none; FFCore.setHeroAction(none);
6402 1079 }
6403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28905 times.
28905 else if (val == -1) ++x;
6404
6405 29984 break;
6406 }
6407 105376 }
6408 26344 }
6409 26424 }
6410
6411
17/20
✓ Branch 0 taken 3195035 times.
✓ Branch 1 taken 2793356 times.
✓ Branch 2 taken 3195035 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3192085 times.
✓ Branch 5 taken 2950 times.
✓ Branch 6 taken 3191422 times.
✓ Branch 7 taken 663 times.
✓ Branch 8 taken 3191422 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3191422 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3191274 times.
✓ Branch 13 taken 148 times.
✓ Branch 14 taken 3189389 times.
✓ Branch 15 taken 1885 times.
✓ Branch 16 taken 1851 times.
✓ Branch 17 taken 3187538 times.
✓ Branch 18 taken 2995403 times.
✓ Branch 19 taken 2997254 times.
5988391 if(hclk>0 || inlikelike == 1 || action==inwind || action==drowning || action==lavadrowning || action==sidedrowning || inwallm || isDiving() || (action==hopping && hopclk<255))
6412 {
6413 5794405 return;
6414 }
6415
6416
2/2
✓ Branch 0 taken 4724261 times.
✓ Branch 1 taken 3187498 times.
7911759 for(int32_t i=0; i<Lwpns.Count(); i++)
6417 {
6418 4724261 sprite *s = Lwpns.spr(i);
6419 4724261 int32_t itemid = ((weapon*)(Lwpns.spr(i)))->parentitem;
6420 //if ( itemdbuf[parentitem].flags&ITEM_FLAGS3 ) //can damage Hero
6421 //if ( itemsbuf[parentitem].misc1 > 0 ) //damages Hero by this amount.
6422
13/14
✓ Branch 0 taken 228380 times.
✓ Branch 1 taken 4495881 times.
✓ Branch 2 taken 1498627 times.
✓ Branch 3 taken 2997254 times.
✓ Branch 4 taken 1498627 times.
✓ Branch 5 taken 1498627 times.
✓ Branch 6 taken 1478964 times.
✓ Branch 7 taken 19663 times.
✓ Branch 8 taken 1478964 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 62500 times.
✓ Branch 11 taken 1416464 times.
✓ Branch 12 taken 39641 times.
✓ Branch 13 taken 22859 times.
4724261 if((!(itemid==-1&&get_bit(quest_rules,qr_FIREPROOFHERO)||((itemid>-1&&itemsbuf[itemid].family==itype_candle||itemsbuf[itemid].family==itype_book)&&(itemsbuf[itemid].flags & ITEM_FLAG3)))) && (scriptcoldet&1) && !fallclk && (!superman || !get_bit(quest_rules,qr_FIREPROOFHERO2)))
6423 {
6424
7/10
✓ Branch 0 taken 1391589 times.
✓ Branch 1 taken 47734 times.
✓ Branch 2 taken 47734 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 47716 times.
✓ Branch 8 taken 1439305 times.
✓ Branch 9 taken 18 times.
1439341 if(s->id==wFire && (superman ? (diagonalMovement?s->hit(x+4,y+4-fakez,z,7,7,1):s->hit(x+7,y+7-fakez,z,2,2,1)) : s->hit(this))&&
6425
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 (itemid < 0 || itemsbuf[itemid].family!=itype_dinsfire))
6426 {
6427 18 std::vector<int32_t> &ev = FFCore.eventData;
6428 18 ev.clear();
6429 18 ev.push_back(lwpn_dp(i)*10000);
6430 18 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6431 18 ev.push_back(0);
6432 18 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6433 18 ev.push_back(48*10000);
6434 18 ev.push_back(ZSD_LWPN*10000);
6435 18 ev.push_back(s->getUID());
6436
6437 18 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6438 18 int32_t dmg = ev[0]/10000;
6439 18 bool nullhit = ev[2] != 0;
6440
6441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(nullhit) {ev.clear(); return;}
6442
6443 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6444 18 ev[0] = ringpower(dmg)*10000;
6445
6446 18 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6447 18 dmg = ev[0]/10000;
6448 18 int32_t hdir = ev[1]/10000;
6449 18 nullhit = ev[2] != 0;
6450 18 bool nayrulove = ev[3] != 0;
6451 18 int32_t iframes = ev[4] / 10000;
6452 18 ev.clear();
6453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(nullhit) return;
6454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(!nayrulove)
6455 {
6456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 game->set_life(zc_max(game->get_life()-dmg,0));
6457 18 }
6458
6459 18 hitdir = hdir;
6460
6461
3/6
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
18 if (action != rafting && action != freeze && action != sideswimfreeze)
6462 {
6463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (IsSideSwim())
6464 {
6465 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6466 }
6467
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
18 else if (action == swimming || hopclk == 0xFF)
6468 {
6469 action=swimhit; FFCore.setHeroAction(swimhit);
6470 }
6471 else
6472 {
6473 18 action=gothit; FFCore.setHeroAction(gothit);
6474 }
6475 18 }
6476
6477
5/8
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 13 times.
18 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6478 {
6479 5 spins = charging = attackclk = 0;
6480 5 attack=none;
6481 5 tapping = false;
6482 5 }
6483
6484 18 hclk=iframes;
6485 18 sfx(getHurtSFX(),pan(x.getInt()));
6486 18 return;
6487 }
6488 1439305 }
6489
6490 // check enemy weapons true, 1, -1
6491 //
6492
2/2
✓ Branch 0 taken 1711410 times.
✓ Branch 1 taken 15579 times.
1726989 if((itemsbuf[itemid].flags & ITEM_FLAG6))
6493 {
6494
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 15579 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
15579 if(s->id==wBrang || (s->id==wHookshot&&!pull_hero))
6495 {
6496
1/2
✓ Branch 0 taken 15579 times.
✗ Branch 1 not taken.
15579 int32_t itemid = ((weapon*)s)->parentitem>-1 ? ((weapon*)s)->parentitem :
6497 directWpn>-1 ? directWpn : current_item_id(s->id==wHookshot ? (((weapon*)s)->family_class == itype_switchhook ? itype_switchhook : itype_hookshot) : itype_brang);
6498 15579 itemid = vbound(itemid, 0, MAXITEMS-1);
6499
6500
2/2
✓ Branch 0 taken 15575 times.
✓ Branch 1 taken 1039 times.
16614 for(int32_t j=0; j<Ewpns.Count(); j++)
6501 {
6502 1039 sprite *t = Ewpns.spr(j);
6503
6504
2/2
✓ Branch 0 taken 1035 times.
✓ Branch 1 taken 4 times.
1039 if(s->hit(t->x+7,t->y+7-t->fakez,t->z,2,2,1))
6505 {
6506 4 bool reflect = false;
6507 // sethitHeroUID(HIT_BY_EWEAPON,j); //set that Hero was hit by a specific eweapon index.
6508
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
4 switch(t->id)
6509 {
6510 case ewBrang:
6511 if(!(itemsbuf[itemid].misc3 & shBRANG)) break;
6512
6513 reflect = ((itemsbuf[itemid].misc4 & shBRANG) != 0);
6514 goto killweapon;
6515
6516 case ewArrow:
6517 if(!(itemsbuf[itemid].misc3 & shARROW)) break;
6518
6519 reflect = ((itemsbuf[itemid].misc4 & shARROW) != 0);
6520 goto killweapon;
6521
6522 case ewRock:
6523 if(!(itemsbuf[itemid].misc3 & shROCK)) break;
6524
6525 reflect = ((itemsbuf[itemid].misc4 & shROCK) != 0);
6526 goto killweapon;
6527
6528 case ewFireball2:
6529 case ewFireball:
6530 {
6531 int32_t mask = (((weapon*)t)->type&1 ? shFIREBALL2 : shFIREBALL);
6532
6533 if(!(itemsbuf[itemid].misc3 & mask)) break;
6534
6535 reflect = ((itemsbuf[itemid].misc4 & mask) != 0);
6536 goto killweapon;
6537 }
6538
6539 case ewSword:
6540 if(!(itemsbuf[itemid].misc3 & shSWORD)) break;
6541
6542 reflect = ((itemsbuf[itemid].misc4 & shSWORD) != 0);
6543 goto killweapon;
6544
6545 case wRefMagic:
6546 case ewMagic:
6547 if(!(itemsbuf[itemid].misc3 & shMAGIC)) break;
6548
6549 reflect = ((itemsbuf[itemid].misc4 & shMAGIC) != 0);
6550 goto killweapon;
6551
6552 case wScript1:
6553 case wScript2:
6554 case wScript3:
6555 case wScript4:
6556 case wScript5:
6557 case wScript6:
6558 case wScript7:
6559 case wScript8:
6560 case wScript9:
6561 case wScript10:
6562 if(!(itemsbuf[itemid].misc3 & shSCRIPT)) break;
6563
6564 reflect = ((itemsbuf[itemid].misc4 & shSCRIPT) != 0);
6565 goto killweapon;
6566
6567 case ewLitBomb:
6568 case ewLitSBomb:
6569 killweapon:
6570 ((weapon*)s)->dead=1;
6571 weapon *ew = ((weapon*)t);
6572 int32_t oldid = ew->id;
6573 ew->onhit(true, reflect ? 2 : 1, s->dir);
6574
6575 if(ew->id != oldid || (ew->id>=wScript1 && ew->id<=wScript10)) // changed type from ewX to wX... Except for script weapons
6576 {
6577 Lwpns.add(ew);
6578 Ewpns.remove(ew);
6579 ew->isLWeapon = true; //Make sure this gets set everywhere!
6580 }
6581
6582 if(ew->id==wRefMagic)
6583 {
6584 ew->ignoreHero=true;
6585 ew->ignorecombo=-1;
6586 }
6587
6588 break;
6589 }
6590
6591 4 break;
6592 }
6593 1035 }
6594 15579 }
6595 15579 }
6596
6597
6/6
✓ Branch 0 taken 1206761 times.
✓ Branch 1 taken 520228 times.
✓ Branch 2 taken 228380 times.
✓ Branch 3 taken 978381 times.
✓ Branch 4 taken 8405 times.
✓ Branch 5 taken 219975 times.
1726989 if((itemsbuf[itemid].flags & ITEM_FLAG2)||(itemid==-1&&get_bit(quest_rules,qr_OUCHBOMBS)))
6598 {
6599
7/10
✓ Branch 0 taken 528529 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 528632 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
528633 if(((s->id==wBomb)||(s->id==wSBomb)) && s->hit(this) && !superman && (scriptcoldet&1) && !fallclk)
6600 {
6601 1 std::vector<int32_t> &ev = FFCore.eventData;
6602 1 ev.clear();
6603
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 ev.push_back(((((weapon*)s)->parentitem>-1 ? itemsbuf[((weapon*)s)->parentitem].misc3 : ((weapon*)s)->power) *game->get_hp_per_heart())*10000);
6604 1 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6605 1 ev.push_back(0);
6606 1 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6607 1 ev.push_back(48*10000);
6608 1 ev.push_back(ZSD_LWPN*10000);
6609 1 ev.push_back(s->getUID());
6610
6611 1 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6612 1 int32_t dmg = ev[0]/10000;
6613 1 bool nullhit = ev[2] != 0;
6614
6615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(nullhit) {ev.clear(); return;}
6616
6617 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6618 1 ev[0] = ringpower(dmg)*10000;
6619
6620 1 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6621 1 dmg = ev[0]/10000;
6622 1 int32_t hdir = ev[1]/10000;
6623 1 nullhit = ev[2] != 0;
6624 1 bool nayrulove = ev[3] != 0;
6625 1 int32_t iframes = ev[4] / 10000;
6626 1 ev.clear();
6627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(nullhit) return;
6628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!nayrulove)
6629 {
6630
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 game->set_life(zc_min(game->get_maxlife(), zc_max(game->get_life()-dmg,0)));
6631 1 }
6632
6633 1 hitdir = hdir;
6634
6635
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 if (action != rafting && action != freeze && action != sideswimfreeze)
6636 {
6637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (IsSideSwim())
6638 {
6639 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6640 }
6641
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 else if (action == swimming || hopclk == 0xFF)
6642 {
6643 action=swimhit; FFCore.setHeroAction(swimhit);
6644 }
6645 else
6646 {
6647 1 action=gothit; FFCore.setHeroAction(gothit);
6648 }
6649 1 }
6650
6651
4/8
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
1 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6652 {
6653 spins = charging = attackclk = 0;
6654 attack=none;
6655 tapping = false;
6656 }
6657
6658 1 hclk=iframes;
6659 1 sfx(getHurtSFX(),pan(x.getInt()));
6660 1 return;
6661 }
6662 528632 }
6663
6664
7/8
✓ Branch 0 taken 1726988 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3335 times.
✓ Branch 3 taken 1723653 times.
✓ Branch 4 taken 3314 times.
✓ Branch 5 taken 21 times.
✓ Branch 6 taken 1726967 times.
✓ Branch 7 taken 21 times.
1726988 if(hclk==0 && s->id==wWind && s->hit(x+7,y+7-fakez,z,2,2,1) && !fairyclk)
6665 {
6666 21 std::vector<int32_t> &ev = FFCore.eventData;
6667 21 ev.clear();
6668 21 ev.push_back(0);
6669 21 ev.push_back(s->dir*10000);
6670 21 ev.push_back(0);
6671 21 ev.push_back(0);
6672 21 ev.push_back(ZSD_LWPN*10000);
6673 21 ev.push_back(s->getUID());
6674
6675 21 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6676 21 bool nullhit = ev[2] != 0;
6677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(nullhit) {ev.clear(); return;}
6678
6679 21 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6680 21 int32_t hdir = ev[1]/10000;
6681 21 nullhit = ev[2] != 0;
6682 21 ev.clear();
6683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(nullhit) return;
6684
6685 21 reset_hookshot();
6686 21 xofs=1000;
6687 21 action=inwind; FFCore.setHeroAction(inwind);
6688 21 dir=s->dir=hdir;
6689 21 spins = charging = attackclk = 0;
6690
6691 // In case Hero used two whistles in a row, summoning two whirlwinds,
6692 // check which whistle's whirlwind picked him up so the correct
6693 // warp ring will be used
6694 21 int32_t whistle=((weapon*)s)->parentitem;
6695
6696
2/4
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
21 if(whistle>-1 && itemsbuf[whistle].family==itype_whistle)
6697 21 whistleitem=whistle;
6698
6699 21 return;
6700 }
6701 1726967 }
6702
6703
6/8
✓ Branch 0 taken 3170448 times.
✓ Branch 1 taken 17050 times.
✓ Branch 2 taken 3122608 times.
✓ Branch 3 taken 47840 times.
✓ Branch 4 taken 3122608 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3122608 times.
6310106 if(action==rafting || action==freeze || action==sideswimfreeze ||
6704
4/8
✓ Branch 0 taken 3122608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3122608 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3122608 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3122608 times.
✗ Branch 7 not taken.
3122608 action==casting || action==sideswimcasting || action==drowning || action==lavadrowning || action==sidedrowning)
6705 64890 return;
6706
6707 3122608 int32_t hit2 = -1;
6708 3122608 do
6709 {
6710
2/2
✓ Branch 0 taken 262250 times.
✓ Branch 1 taken 2863048 times.
3125298 hit2 = diagonalMovement ? GuyHitFrom(hit2+1,x+4,y+4-fakez,z,8,8,hzsz)
6711 2863048 : GuyHitFrom(hit2+1,x+7,y+7-fakez,z,2,2,hzsz);
6712
6713
2/2
✓ Branch 0 taken 3116196 times.
✓ Branch 1 taken 9102 times.
3125298 if(hit2!=-1)
6714 {
6715
2/2
✓ Branch 0 taken 2690 times.
✓ Branch 1 taken 6412 times.
9102 if (hithero(hit2) == 0) return;
6716 2690 }
6717
2/2
✓ Branch 0 taken 2690 times.
✓ Branch 1 taken 3116196 times.
3118886 } while (hit2 != -1);
6718
6/6
✓ Branch 0 taken 3015564 times.
✓ Branch 1 taken 100632 times.
✓ Branch 2 taken 3004462 times.
✓ Branch 3 taken 11102 times.
✓ Branch 4 taken 173 times.
✓ Branch 5 taken 3004289 times.
3116196 if (superman || !(scriptcoldet&1) || fallclk) return;
6719 3004289 hit2 = LwpnHit();
6720
6721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3004289 times.
3004289 if(hit2!=-1)
6722 {
6723 weapon* lwpnspr = (weapon*)Lwpns.spr(hit2);
6724 std::vector<int32_t> &ev = FFCore.eventData;
6725 ev.clear();
6726 ev.push_back((lwpn_dp(hit2)*10000));
6727 ev.push_back(lwpnspr->hitdir(x,y,16,16,dir)*10000);
6728 ev.push_back(0);
6729 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6730 ev.push_back(48*10000);
6731 ev.push_back(ZSD_LWPN*10000);
6732 ev.push_back(lwpnspr->getUID());
6733
6734 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6735 int32_t dmg = ev[0]/10000;
6736 bool nullhit = ev[2] != 0;
6737
6738 if(nullhit) {ev.clear(); return;}
6739
6740 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6741 ev[0] = ringpower(dmg)*10000;
6742
6743 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6744 dmg = ev[0]/10000;
6745 int32_t hdir = ev[1]/10000;
6746 nullhit = ev[2] != 0;
6747 bool nayrulove = ev[3] != 0;
6748 int32_t iframes = ev[4] / 10000;
6749 ev.clear();
6750 if(nullhit) return;
6751 if(!nayrulove)
6752 {
6753 game->set_life(zc_max(game->get_life()-dmg,0));
6754 sethitHeroUID(HIT_BY_LWEAPON,(hit2+1));
6755 sethitHeroUID(HIT_BY_LWEAPON_UID,lwpnspr->getUID());
6756 }
6757
6758 hitdir = hdir;
6759 lwpnspr->onhit(false);
6760
6761 if (IsSideSwim())
6762 {
6763 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6764 }
6765 else if(action==swimming || hopclk==0xFF)
6766 {
6767 action=swimhit; FFCore.setHeroAction(swimhit);
6768 }
6769 else
6770 {
6771 action=gothit; FFCore.setHeroAction(gothit);
6772 }
6773
6774 hclk=iframes;
6775
6776 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6777 {
6778 spins = charging = attackclk = 0;
6779 attack=none;
6780 tapping = false;
6781 }
6782
6783 sfx(getHurtSFX(),pan(x.getInt()));
6784 return;
6785 }
6786
6787 //else { sethitHeroUID(HIT_BY_LWEAPON,(0)); //fails to clear
6788
6789 3004289 hit2 = EwpnHit();
6790
6791
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 3002324 times.
3004289 if(hit2!=-1)
6792 {
6793 1965 weapon* ewpnspr = (weapon*)Ewpns.spr(hit2);
6794 1965 std::vector<int32_t> &ev = FFCore.eventData;
6795 1965 ev.clear();
6796 1965 ev.push_back((ewpn_dp(hit2)*10000));
6797 1965 ev.push_back(ewpnspr->hitdir(x,y,16,16,dir)*10000);
6798 1965 ev.push_back(0);
6799 1965 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6800 1965 ev.push_back(48*10000);
6801 1965 ev.push_back(ZSD_EWPN*10000);
6802 1965 ev.push_back(ewpnspr->getUID());
6803
6804 1965 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6805 1965 int32_t dmg = ev[0]/10000;
6806 1965 bool nullhit = ev[2] != 0;
6807
6808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if(nullhit) {ev.clear(); return;}
6809
6810 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6811 1965 ev[0] = ringpower(dmg)*10000;
6812
6813 1965 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6814 1965 dmg = ev[0]/10000;
6815 1965 int32_t hdir = ev[1]/10000;
6816 1965 nullhit = ev[2] != 0;
6817 1965 bool nayrulove = ev[3] != 0;
6818 1965 int32_t iframes = ev[4] / 10000;
6819 1965 ev.clear();
6820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if(nullhit) return;
6821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if(!nayrulove)
6822 {
6823
2/2
✓ Branch 0 taken 1957 times.
✓ Branch 1 taken 8 times.
1965 game->set_life(zc_max(game->get_life()-dmg,0));
6824 1965 sethitHeroUID(HIT_BY_EWEAPON,(hit2+1));
6825 1965 sethitHeroUID(HIT_BY_EWEAPON_UID,ewpnspr->getUID());
6826 1965 }
6827
6828 1965 hitdir = hdir;
6829 1965 ewpnspr->onhit(false);
6830
6831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if (IsSideSwim())
6832 {
6833 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6834 }
6835
3/4
✓ Branch 0 taken 1956 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1956 times.
1965 else if(action==swimming || hopclk==0xFF)
6836 {
6837 9 action=swimhit; FFCore.setHeroAction(swimhit);
6838 9 }
6839 else
6840 {
6841 1956 action=gothit; FFCore.setHeroAction(gothit);
6842 }
6843
6844 1965 hclk=iframes;
6845
6846
6/8
✓ Branch 0 taken 1962 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1962 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 552 times.
✓ Branch 5 taken 1410 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 552 times.
1965 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6847 {
6848 1413 spins = charging = attackclk = 0;
6849 1413 attack=none;
6850 1413 tapping = false;
6851 1413 }
6852
6853 1965 sfx(getHurtSFX(),pan(x.getInt()));
6854 1965 return;
6855 }
6856 //else { sethitHeroUID(HIT_BY_EWEAPON,(0)); } //fails to clear
6857
6858 // The rest of this method deals with damage combos, which can be jumped over.
6859
4/4
✓ Branch 0 taken 2999056 times.
✓ Branch 1 taken 3268 times.
✓ Branch 2 taken 2999056 times.
✓ Branch 3 taken 3268 times.
3002324 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) return;
6860
6861 2999056 int32_t dx1 = (int32_t)x+8-(tmpscr->csensitive);
6862 2999056 int32_t dx2 = (int32_t)x+8+(tmpscr->csensitive-1);
6863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2999056 times.
2999056 int32_t dy1 = (int32_t)y+(bigHitbox?8:12)-(bigHitbox?tmpscr->csensitive:(tmpscr->csensitive+1)/2);
6864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2999056 times.
2999056 int32_t dy2 = (int32_t)y+(bigHitbox?8:12)+(bigHitbox?tmpscr->csensitive-1:((tmpscr->csensitive+1)/2)-1);
6865
6866
2/2
✓ Branch 0 taken 2999056 times.
✓ Branch 1 taken 6074994 times.
9074050 for(int32_t i=get_bit(quest_rules, qr_DMGCOMBOLAYERFIX) ? 1 : -1; i>=-1; i--) // Layers 0, 1 and 2!!
6867 6074994 (void)checkdamagecombos(dx1,dx2,dy1,dy2,i);
6868 3395231 }
6869
6870 1549 bool HeroClass::checkdamagecombos(int32_t dx, int32_t dy)
6871 {
6872 1549 return checkdamagecombos(dx,dx,dy,dy);
6873 }
6874
6875 72 void HeroClass::doHit(int32_t hdir)
6876 {
6877 72 hitdir = hdir;
6878
6879
3/6
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 72 times.
72 if (action != rafting && action != freeze && action != sideswimfreeze)
6880 {
6881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if (IsSideSwim())
6882 {
6883 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6884 }
6885
2/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
72 else if (action == swimming || hopclk == 0xFF)
6886 {
6887 action=swimhit; FFCore.setHeroAction(swimhit);
6888 }
6889 else
6890 {
6891 72 action=gothit; FFCore.setHeroAction(gothit);
6892 }
6893 72 }
6894
6895 72 hclk=48;
6896
6897
5/8
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 27 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 45 times.
72 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6898 {
6899 27 spins = charging = attackclk = 0;
6900 27 attack=none;
6901 27 tapping = false;
6902 27 }
6903
6904 72 sfx(getHurtSFX(),pan(x.getInt()));
6905 72 }
6906
6907 6263862 bool HeroClass::checkdamagecombos(int32_t dx1, int32_t dx2, int32_t dy1, int32_t dy2, int32_t layer, bool solid, bool do_health_check) //layer = -1, solid = false, do_health_check = true
6908 {
6909
5/6
✓ Branch 0 taken 6263859 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 6258975 times.
✓ Branch 3 taken 4884 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6258975 times.
6263862 if(hclk || superman || fallclk)
6910 4887 return false;
6911
6912 6258975 int32_t hp_mod[4] = {0};
6913 int32_t cid[8];
6914 6258975 byte hasKB = 0;
6915
6916 {
6917
2/2
✓ Branch 0 taken 3197485 times.
✓ Branch 1 taken 3061490 times.
6258975 cid[0] = layer>-1?MAPCOMBO2(layer,dx1,dy1):MAPCOMBO(dx1,dy1);
6918 6258975 newcombo& cmb = combobuf[cid[0]];
6919
3/4
✓ Branch 0 taken 6258975 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6258918 times.
✓ Branch 3 taken 57 times.
6258975 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6920 {
6921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(cmb.usrflags&cflag1)
6922 hp_mod[0] = cmb.attributes[0] / -10000L;
6923 else
6924 57 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
6925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(!(cmb.usrflags&cflag2))
6926 57 hasKB |= 1<<0;
6927 57 }
6928 }
6929 {
6930
2/2
✓ Branch 0 taken 3197485 times.
✓ Branch 1 taken 3061490 times.
6258975 cid[1] = layer>-1?MAPCOMBO2(layer,dx1,dy2):MAPCOMBO(dx1,dy2);
6931 6258975 newcombo& cmb = combobuf[cid[1]];
6932
3/4
✓ Branch 0 taken 6258975 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6258912 times.
✓ Branch 3 taken 63 times.
6258975 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6933 {
6934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(cmb.usrflags&cflag1)
6935 hp_mod[1] = cmb.attributes[0] / -10000L;
6936 else
6937 63 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
6938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(!(cmb.usrflags&cflag2))
6939 63 hasKB |= 1<<1;
6940 63 }
6941 }
6942 {
6943
2/2
✓ Branch 0 taken 3197485 times.
✓ Branch 1 taken 3061490 times.
6258975 cid[2] = layer>-1?MAPCOMBO2(layer,dx2,dy1):MAPCOMBO(dx2,dy1);
6944 6258975 newcombo& cmb = combobuf[cid[2]];
6945
3/4
✓ Branch 0 taken 6258975 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6258912 times.
✓ Branch 3 taken 63 times.
6258975 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6946 {
6947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(cmb.usrflags&cflag1)
6948 hp_mod[2] = cmb.attributes[0] / -10000L;
6949 else
6950 63 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
6951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(!(cmb.usrflags&cflag2))
6952 63 hasKB |= 1<<2;
6953 63 }
6954 }
6955 {
6956
2/2
✓ Branch 0 taken 3197485 times.
✓ Branch 1 taken 3061490 times.
6258975 cid[3] = layer>-1?MAPCOMBO2(layer,dx2,dy2):MAPCOMBO(dx2,dy2);
6957 6258975 newcombo& cmb = combobuf[cid[3]];
6958
3/4
✓ Branch 0 taken 6258975 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6258908 times.
✓ Branch 3 taken 67 times.
6258975 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6959 {
6960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(cmb.usrflags&cflag1)
6961 hp_mod[3] = cmb.attributes[0] / -10000L;
6962 else
6963 67 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
6964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(!(cmb.usrflags&cflag2))
6965 67 hasKB |= 1<<3;
6966 67 }
6967 }
6968
6969 6258975 int32_t bestcid=0;
6970 6258975 int32_t hp_modtotal=0;
6971
2/2
✓ Branch 0 taken 4060285 times.
✓ Branch 1 taken 2198690 times.
6258975 if (!_effectflag(dx1,dy1,1, layer)) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6972
2/2
✓ Branch 0 taken 4058225 times.
✓ Branch 1 taken 2200750 times.
6258975 if (!_effectflag(dx1,dy2,1, layer)) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6973
2/2
✓ Branch 0 taken 4060317 times.
✓ Branch 1 taken 2198658 times.
6258975 if (!_effectflag(dx2,dy1,1, layer)) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6974
2/2
✓ Branch 0 taken 4058258 times.
✓ Branch 1 taken 2200717 times.
6258975 if (!_effectflag(dx2,dy2,1, layer)) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6975
6976
2/2
✓ Branch 0 taken 12517950 times.
✓ Branch 1 taken 6258975 times.
18776925 for (int32_t i = 0; i <= 1; ++i)
6977 {
6978
2/2
✓ Branch 0 taken 9370224 times.
✓ Branch 1 taken 3147726 times.
12517950 if(tmpscr2[i].valid!=0)
6979 {
6980
2/2
✓ Branch 0 taken 2828879 times.
✓ Branch 1 taken 318847 times.
3147726 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
6981 {
6982
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2828879 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2828879 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6983
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2828879 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2828879 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6984
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2828879 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2828879 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6985
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2828879 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2828879 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6986 2828879 }
6987 else
6988 {
6989
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 318748 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
318847 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6990
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 318748 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
318847 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6991
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 318748 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
318847 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6992
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 318748 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
318847 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6993 }
6994 3147726 }
6995 12517950 }
6996
6997
2/2
✓ Branch 0 taken 25035900 times.
✓ Branch 1 taken 6258975 times.
31294875 for(int32_t i=0; i<4; i++)
6998 {
6999
2/2
✓ Branch 0 taken 15524392 times.
✓ Branch 1 taken 9511508 times.
25035900 if(get_bit(quest_rules,qr_DMGCOMBOPRI))
7000 {
7001
2/2
✓ Branch 0 taken 15524232 times.
✓ Branch 1 taken 160 times.
15524392 if(hp_modtotal >= 0) //Okay, if it's over 0, it's healing Hero.
7002 {
7003
2/2
✓ Branch 0 taken 15524169 times.
✓ Branch 1 taken 63 times.
15524232 if(hp_mod[i] < hp_modtotal)
7004 {
7005 63 hp_modtotal = hp_mod[i];
7006 63 bestcid = cid[i];
7007 63 }
7008 15524232 }
7009
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 139 times.
160 else if(hp_mod[i] < 0) //If it's under 0, it's hurting Hero.
7010 {
7011
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(hp_mod[i] > hp_modtotal)
7012 {
7013 hp_modtotal = hp_mod[i];
7014 bestcid = cid[i];
7015 }
7016 139 }
7017 15524392 }
7018
2/2
✓ Branch 0 taken 9511495 times.
✓ Branch 1 taken 13 times.
9511508 else if(hp_mod[i] < hp_modtotal)
7019 {
7020 13 hp_modtotal = hp_mod[i];
7021 13 bestcid = cid[i];
7022 13 }
7023 25035900 }
7024
7025 {
7026 6258975 cid[4] = MAPFFCOMBO(dx1,dy1);
7027 6258975 newcombo& cmb = combobuf[cid[4]];
7028
3/4
✓ Branch 0 taken 6258975 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6258625 times.
✓ Branch 3 taken 350 times.
6258975 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7029 {
7030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 if(cmb.usrflags&cflag1 )
7031 hp_mod[0] = cmb.attributes[0]/10000L;
7032 else
7033 350 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
7034
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 if(!(cmb.usrflags&cflag2))
7035 hasKB |= 1<<4;
7036 350 }
7037 }
7038 {
7039 6258975 cid[5] = MAPFFCOMBO(dx1,dy2);
7040 6258975 newcombo& cmb = combobuf[cid[5]];
7041
3/4
✓ Branch 0 taken 6258975 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6258634 times.
✓ Branch 3 taken 341 times.
6258975 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7042 {
7043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 341 times.
341 if(cmb.usrflags&cflag1 )
7044 hp_mod[1] = cmb.attributes[0]/10000L;
7045 else
7046 341 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
7047
1/2
✓ Branch 0 taken 341 times.
✗ Branch 1 not taken.
341 if(!(cmb.usrflags&cflag2))
7048 hasKB |= 1<<5;
7049 341 }
7050 }
7051 {
7052 6258975 cid[6] = MAPFFCOMBO(dx2,dy1);
7053 6258975 newcombo& cmb = combobuf[cid[6]];
7054
3/4
✓ Branch 0 taken 6258975 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6258613 times.
✓ Branch 3 taken 362 times.
6258975 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7055 {
7056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 362 times.
362 if(cmb.usrflags&cflag1 )
7057 hp_mod[2] = cmb.attributes[0]/10000L;
7058 else
7059 362 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
7060
1/2
✓ Branch 0 taken 362 times.
✗ Branch 1 not taken.
362 if(!(cmb.usrflags&cflag2))
7061 hasKB |= 1<<6;
7062 362 }
7063 }
7064 {
7065 6258975 cid[7] = MAPFFCOMBO(dx2,dy2);
7066 6258975 newcombo& cmb = combobuf[cid[7]];
7067
3/4
✓ Branch 0 taken 6258975 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6258634 times.
✓ Branch 3 taken 341 times.
6258975 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7068 {
7069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 341 times.
341 if(cmb.usrflags&cflag1 )
7070 hp_mod[3] = cmb.attributes[0]/10000L;
7071 else
7072 341 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
7073
1/2
✓ Branch 0 taken 341 times.
✗ Branch 1 not taken.
341 if(!(cmb.usrflags&cflag2))
7074 hasKB |= 1<<7;
7075 341 }
7076 }
7077
7078 6258975 int32_t bestffccid = 0;
7079 6258975 int32_t hp_modtotalffc = 0;
7080
7081
2/2
✓ Branch 0 taken 12517950 times.
✓ Branch 1 taken 6258975 times.
18776925 for (int32_t i = 0; i <= 1; ++i)
7082 {
7083
2/2
✓ Branch 0 taken 9370224 times.
✓ Branch 1 taken 3147726 times.
12517950 if(tmpscr2[i].valid!=0)
7084 {
7085
2/2
✓ Branch 0 taken 2828879 times.
✓ Branch 1 taken 318847 times.
3147726 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
7086 {
7087
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2828879 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2828879 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7088
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2828879 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2828879 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7089
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2828879 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2828879 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7090
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2828879 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2828879 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7091 2828879 }
7092 else
7093 {
7094
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 318748 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
318847 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7095
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 318748 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
318847 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7096
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 318748 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
318847 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7097
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 318748 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
318847 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7098 }
7099 3147726 }
7100 12517950 }
7101
7102
2/2
✓ Branch 0 taken 25035900 times.
✓ Branch 1 taken 6258975 times.
31294875 for(int32_t i=0; i<4; i++)
7103 {
7104
2/2
✓ Branch 0 taken 15524392 times.
✓ Branch 1 taken 9511508 times.
25035900 if(get_bit(quest_rules,qr_DMGCOMBOPRI))
7105 {
7106
2/2
✓ Branch 0 taken 15524232 times.
✓ Branch 1 taken 160 times.
15524392 if(hp_modtotalffc >= 0)
7107 {
7108
2/2
✓ Branch 0 taken 15524169 times.
✓ Branch 1 taken 63 times.
15524232 if(hp_mod[i] < hp_modtotalffc)
7109 {
7110 63 hp_modtotalffc = hp_mod[i];
7111 63 bestffccid = cid[4+i];
7112 63 }
7113 15524232 }
7114
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 139 times.
160 else if(hp_mod[i] < 0)
7115 {
7116
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(hp_mod[i] > hp_modtotalffc)
7117 {
7118 hp_modtotalffc = hp_mod[i];
7119 bestffccid = cid[4+i];
7120 }
7121 139 }
7122 15524392 }
7123
2/2
✓ Branch 0 taken 9511112 times.
✓ Branch 1 taken 396 times.
9511508 else if(hp_mod[i] < hp_modtotalffc)
7124 {
7125 396 hp_modtotalffc = hp_mod[i];
7126 396 bestffccid = cid[4+i];
7127 396 }
7128 25035900 }
7129
7130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6258975 times.
6258975 int32_t hp_modmin = zc_min(hp_modtotal, hp_modtotalffc);
7131
1/2
✓ Branch 0 taken 6258975 times.
✗ Branch 1 not taken.
6258975 if(hp_modtotalffc < hp_modmin) bestcid = bestffccid;
7132
7133 6258975 bool global_defring = ((itemsbuf[current_item_id(itype_ring)].flags & ITEM_FLAG1));
7134 6258975 bool global_perilring = ((itemsbuf[current_item_id(itype_perilring)].flags & ITEM_FLAG1));
7135 6258975 bool current_ring = ((tmpscr->flags6&fTOGGLERINGDAMAGE) != 0);
7136
1/2
✓ Branch 0 taken 6258975 times.
✗ Branch 1 not taken.
6258975 if(current_ring)
7137 {
7138 global_defring = !global_defring;
7139 global_perilring = !global_perilring;
7140 }
7141 6258975 int32_t itemid = current_item_id(itype_boots);
7142
7143
2/2
✓ Branch 0 taken 6210459 times.
✓ Branch 1 taken 48516 times.
6258975 bool bootsnosolid = itemid >= 0 && 0 != (itemsbuf[itemid].flags & ITEM_FLAG1);
7144
2/2
✓ Branch 0 taken 6210459 times.
✓ Branch 1 taken 48516 times.
6258975 bool ignoreBoots = itemid >= 0 && (itemsbuf[itemid].flags & ITEM_FLAG3);
7145
7146
2/2
✓ Branch 0 taken 6258516 times.
✓ Branch 1 taken 459 times.
6258975 if(hp_modmin<0)
7147 {
7148
8/14
✓ Branch 0 taken 374 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 374 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 374 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 374 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 374 times.
✓ Branch 10 taken 374 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 374 times.
459 if((itemid<0) || ignoreBoots || (tmpscr->flags5&fDAMAGEWITHBOOTS) || (4<<current_item_power(itype_boots)<(abs(hp_modmin))) || (solid && bootsnosolid) || !(checkbunny(itemid) && checkmagiccost(itemid)))
7149 {
7150
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 14 times.
85 if (!do_health_check) return true;
7151 71 std::vector<int32_t> &ev = FFCore.eventData;
7152 71 ev.clear();
7153 71 ev.push_back(-hp_modmin*10000);
7154
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 3 times.
71 ev.push_back((hasKB ? dir^1 : -1)*10000);
7155 71 ev.push_back(0);
7156 71 ev.push_back(NayrusLoveShieldClk>0?10000:0);
7157 71 ev.push_back(48*10000);
7158 71 ev.push_back(ZSD_COMBODATA*10000);
7159 71 ev.push_back(bestcid);
7160
7161 71 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7162 71 int32_t dmg = ev[0]/10000;
7163 71 bool nullhit = ev[2] != 0;
7164
7165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 if(nullhit) {ev.clear(); return false;}
7166
7167 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7168 71 ev[0] = ringpower(dmg, !global_perilring, !global_defring)*10000;
7169
7170 71 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7171 71 dmg = ev[0]/10000;
7172 71 int32_t hdir = ev[1]/10000;
7173 71 nullhit = ev[2] != 0;
7174 71 bool nayrulove = ev[3] != 0;
7175 71 int32_t iframes = ev[4] / 10000;
7176 71 ev.clear();
7177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 if(nullhit) return false;
7178
7179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 if(!nayrulove)
7180 {
7181
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 1 times.
71 game->set_life(zc_max(game->get_life()-dmg,0));
7182 71 }
7183
7184 71 hitdir = hdir;
7185 71 doHit(hitdir);
7186 71 hclk = iframes;
7187 71 return true;
7188 }
7189
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 50 times.
374 else if (do_health_check) paymagiccost(itemid); // Boots are successful
7190 374 }
7191
7192 6258890 return false;
7193 6263862 }
7194
7195 9161 int32_t HeroClass::hithero(int32_t hit2, int32_t force_hdir)
7196 {
7197
1/2
✓ Branch 0 taken 9161 times.
✗ Branch 1 not taken.
9161 if(force_hdir > 3) force_hdir = -1;
7198 9161 enemy* enemyptr = (enemy*)guys.spr(hit2);
7199
1/2
✓ Branch 0 taken 9161 times.
✗ Branch 1 not taken.
9161 if(!enemyptr) return 0;
7200 //printf("Stomp check: %d <= 12, %d < %d\n", int32_t((y+16)-(((enemy*)guys.spr(hit2))->y)), (int32_t)falling_oldy, (int32_t)y);
7201 9161 int32_t stompid = current_item_id(itype_stompboots);
7202
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 9161 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
9161 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
7203 ((z+fakez) > (enemyptr->z+(enemyptr->fakez))) ||
7204 ((isSideViewHero() && (y+16)-(enemyptr->y)<=14) && falling_oldy<y)))
7205 {
7206 paymagiccost(stompid);
7207 hit_enemy(hit2,wStomp,itemsbuf[stompid].power*game->get_hero_dmgmult(),x,y,0,stompid);
7208
7209 if(itemsbuf[stompid].flags & ITEM_FLAG1)
7210 {
7211 fall = -(itemsbuf[stompid].misc1);
7212 }
7213
7214 if(itemsbuf[stompid].flags & ITEM_DOWNGRADE)
7215 game->set_item(stompid,false);
7216
7217 // Stomp Boots script
7218 if(itemsbuf[stompid].script != 0 && !(item_doscript[stompid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
7219 {
7220 //clear the item script stack for a new script
7221 ri = &(itemScriptData[stompid]);
7222 for ( int32_t q = 0; q < 1024; q++ ) item_stack[stompid][q] = 0xFFFF;
7223 ri->Clear();
7224 //itemScriptData[(stompid & 0xFFF)].Clear();
7225 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(stompid & 0xFFF)][q] = 0;
7226 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[stompid].script, stompid & 0xFFF);
7227 item_doscript[stompid] = 1;
7228 itemscriptInitialised[stompid] = 0;
7229 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[stompid].script, stompid);
7230 }
7231
7232 return -1;
7233 }
7234
5/6
✓ Branch 0 taken 5912 times.
✓ Branch 1 taken 3249 times.
✓ Branch 2 taken 4961 times.
✓ Branch 3 taken 951 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4961 times.
9161 else if(superman || !(scriptcoldet&1) || fallclk)
7235 4200 return 0;
7236 //!TODO SOLIDPUSH Enemy flag to make them not deal contact damage
7237 //!Add a flag check to this if:
7238
5/6
✓ Branch 0 taken 2431 times.
✓ Branch 1 taken 2530 times.
✓ Branch 2 taken 2431 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1508 times.
✓ Branch 5 taken 923 times.
4961 else if (!(enemyptr->stunclk==0 && enemyptr->frozenclock==0 && (!get_bit(quest_rules, qr_SAFEENEMYFADE) || enemyptr->fading != fade_flicker)
7239
3/4
✓ Branch 0 taken 1329 times.
✓ Branch 1 taken 179 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2252 times.
2431 && (enemyptr->d->family != eeGUY || enemyptr->dmisc1)))
7240 {
7241 2709 return -1;
7242 }
7243
7244 2252 std::vector<int32_t> &ev = FFCore.eventData;
7245 2252 ev.clear();
7246 //Args: 'damage (pre-ring)','hitdir','nullifyhit','type:npc','npc uid'
7247 2252 ev.push_back((enemy_dp(hit2) *10000));
7248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2252 times.
2252 ev.push_back((force_hdir>-1 ? force_hdir : ((sprite*)enemyptr)->hitdir(x,y,16,16,dir))*10000);
7249 2252 ev.push_back(0);
7250 2252 ev.push_back(NayrusLoveShieldClk>0?10000:0);
7251 2252 ev.push_back(48*10000);
7252 2252 ev.push_back(ZSD_NPC*10000);
7253 2252 ev.push_back(enemyptr->getUID());
7254
7255 2252 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7256 2252 int32_t dmg = ev[0] / 10000;
7257 2252 bool nullhit = ev[2] != 0;
7258
7259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2252 times.
2252 if(nullhit) {ev.clear(); return -1;}
7260
7261 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7262 2252 ev[0] = ((ringpower(dmg)*10000));
7263
7264 2252 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7265 2252 dmg = ev[0] / 10000;
7266 2252 int32_t hdir = ev[1] / 10000;
7267 2252 nullhit = ev[2] != 0;
7268 2252 bool nayrulove = ev[3] != 0;
7269 2252 int32_t iframes = ev[4] / 10000;
7270 2252 ev.clear();
7271
7272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2252 times.
2252 if(nullhit) return -1;
7273
7274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2252 times.
2252 if(!nayrulove)
7275 {
7276
2/2
✓ Branch 0 taken 2237 times.
✓ Branch 1 taken 15 times.
2252 game->set_life(zc_max(game->get_life()-dmg,0));
7277 2252 sethitHeroUID(HIT_BY_NPC,(hit2+1));
7278 2252 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->getUID());
7279 2252 }
7280
7281 2252 hitdir = hdir;
7282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2252 times.
2252 if (IsSideSwim())
7283 {
7284 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7285 }
7286
3/4
✓ Branch 0 taken 2234 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2234 times.
2252 else if(action==swimming || hopclk==0xFF)
7287 {
7288 18 action=swimhit; FFCore.setHeroAction(swimhit);
7289 18 }
7290 else
7291 {
7292 2234 action=gothit; FFCore.setHeroAction(gothit);
7293 }
7294
7295 2252 hclk=iframes;
7296 2252 sfx(getHurtSFX(),pan(x.getInt()));
7297
7298
7/8
✓ Branch 0 taken 2250 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2250 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 723 times.
✓ Branch 5 taken 1527 times.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 716 times.
2252 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7299 {
7300 1536 spins = charging = attackclk = 0;
7301 1536 attack=none;
7302 1536 tapping = false;
7303 1536 }
7304
7305 2252 enemy_scored(hit2);
7306 2252 int32_t dm7 = enemyptr->dmisc7;
7307 2252 int32_t dm8 = enemyptr->dmisc8;
7308
7309
3/3
✓ Branch 0 taken 970 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1279 times.
2252 switch(enemyptr->family)
7310 {
7311 case eeWALLM:
7312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(enemyptr->hp>0)
7313 {
7314 3 GrabHero(hit2);
7315 3 inwallm=true;
7316 3 action=none; FFCore.setHeroAction(none);
7317 3 }
7318 3 break;
7319
7320 //case eBUBBLEST:
7321 //case eeBUBBLE:
7322 case eeWALK:
7323 {
7324 1279 int32_t itemid = current_item_id(itype_whispring);
7325 //I can only assume these are supposed to be int32_t, not bool ~pkmnfrk
7326
3/4
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 1119 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
1279 int32_t sworddivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 1) ? itemsbuf[itemid].power : 1);
7327
3/4
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 1119 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
1279 int32_t itemdivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 2) ? itemsbuf[itemid].power : 1);
7328
7329
5/7
✓ Branch 0 taken 979 times.
✓ Branch 1 taken 175 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21 times.
✗ Branch 6 not taken.
1279 switch(dm7)
7330 {
7331 case e7tTEMPJINX:
7332
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 156 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
175 if(dm8==0 || dm8==2)
7333
4/4
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 152 times.
308 if(swordclk>=0 && !(sworddivisor==0))
7334 152 swordclk=150;
7335
7336
3/4
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 156 times.
175 if(dm8==1 || dm8==2)
7337
3/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 18 times.
37 if(itemclk>=0 && !(itemdivisor==0))
7338 18 itemclk=150;
7339
7340 175 break;
7341
7342 case e7tPERMJINX:
7343
3/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
46 if(dm8==0 || dm8==2)
7344
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
30 if(sworddivisor) swordclk=(itemid >-1 && itemsbuf[itemid].flags & ITEM_FLAG1)? int32_t(150/sworddivisor) : -1;
7345
7346
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
46 if(dm8==1 || dm8==2)
7347
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
16 if(itemdivisor) itemclk=(itemid >-1 && itemsbuf[itemid].flags & ITEM_FLAG1)? int32_t(150/itemdivisor) : -1;
7348
7349 46 break;
7350
7351 case e7tUNJINX:
7352
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
58 if(dm8==0 || dm8==2)
7353 46 swordclk=0;
7354
7355
3/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46 times.
58 if(dm8==1 || dm8==2)
7356 12 itemclk=0;
7357
7358 58 break;
7359
7360 case e7tTAKEMAGIC:
7361 game->change_dmagic(-dm8*game->get_magicdrainrate());
7362 break;
7363
7364 case e7tTAKERUPEES:
7365 21 game->change_drupy(-dm8);
7366 21 break;
7367
7368 case e7tDRUNK:
7369 drunkclk += dm8;
7370 break;
7371 }
7372 1279 verifyAWpn();
7373
2/2
✓ Branch 0 taken 1235 times.
✓ Branch 1 taken 44 times.
1279 if(dm7 >= e7tEATITEMS)
7374 {
7375 44 EatHero(hit2);
7376 44 inlikelike=(dm7 == e7tEATHURT ? 2:1);
7377 44 action=none; FFCore.setHeroAction(none);
7378 44 }
7379 }
7380 1279 }
7381 2252 return 0;
7382 9161 }
7383
7384 190367 void HeroClass::addsparkle(int32_t wpn)
7385 {
7386 //return;
7387 190367 weapon *w = (weapon*)Lwpns.spr(wpn);
7388 190367 int32_t itemid = w->parentitem;
7389
7390
1/2
✓ Branch 0 taken 190367 times.
✗ Branch 1 not taken.
190367 if(itemid<0)
7391 return;
7392
7393 190367 int32_t itemtype = itemsbuf[itemid].family;
7394
7395
3/4
✓ Branch 0 taken 190367 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47595 times.
✓ Branch 3 taken 142772 times.
190367 if(itemtype!=itype_cbyrna && frame%4)
7396 142772 return;
7397
7398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47595 times.
47595 int32_t wpn2 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn4 : itemsbuf[itemid].wpn2;
7399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47595 times.
47595 int32_t wpn3 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn5 : itemsbuf[itemid].wpn3;
7400 // Either one (wpn2) or the other (wpn3). If both are present, randomise.
7401
4/8
✓ Branch 0 taken 20684 times.
✓ Branch 1 taken 26911 times.
✓ Branch 2 taken 26911 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 20684 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
47595 int32_t sparkle_type = (!wpn2 ? (!wpn3 ? 0 : wpn3) : (!wpn3 ? wpn2 : (zc_oldrand()&1 ? wpn2 : wpn3)));
7402 47595 int32_t direction=w->dir;
7403
7404
2/2
✓ Branch 0 taken 26911 times.
✓ Branch 1 taken 20684 times.
47595 if(sparkle_type)
7405 {
7406 20684 int32_t h=0;
7407 20684 int32_t v=0;
7408
7409
6/6
✓ Branch 0 taken 15923 times.
✓ Branch 1 taken 4761 times.
✓ Branch 2 taken 14383 times.
✓ Branch 3 taken 1540 times.
✓ Branch 4 taken 2850 times.
✓ Branch 5 taken 11533 times.
20684 if(w->dir==right||w->dir==r_up||w->dir==r_down)
7410 {
7411 9151 h=-1;
7412 9151 }
7413
7414
6/6
✓ Branch 0 taken 16020 times.
✓ Branch 1 taken 4664 times.
✓ Branch 2 taken 13492 times.
✓ Branch 3 taken 2528 times.
✓ Branch 4 taken 1569 times.
✓ Branch 5 taken 11923 times.
20684 if(w->dir==left||w->dir==l_up||w->dir==l_down)
7415 {
7416 8761 h=1;
7417 8761 }
7418
7419
6/6
✓ Branch 0 taken 19411 times.
✓ Branch 1 taken 1273 times.
✓ Branch 2 taken 17842 times.
✓ Branch 3 taken 1569 times.
✓ Branch 4 taken 2850 times.
✓ Branch 5 taken 14992 times.
20684 if(w->dir==down||w->dir==l_down||w->dir==r_down)
7420 {
7421 5692 v=-1;
7422 5692 }
7423
7424
6/6
✓ Branch 0 taken 19185 times.
✓ Branch 1 taken 1499 times.
✓ Branch 2 taken 16657 times.
✓ Branch 3 taken 2528 times.
✓ Branch 4 taken 1540 times.
✓ Branch 5 taken 15117 times.
20684 if(w->dir==up||w->dir==l_up||w->dir==r_up)
7425 {
7426 5567 v=1;
7427 5567 }
7428
7429 // Damaging boomerang sparkle?
7430
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20684 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20684 if(wpn3 && itemtype==itype_brang)
7431 {
7432 // If the boomerang just bounced, flip the sparkle direction so it doesn't hit
7433 // whatever it just bounced off of if it's shielded from that direction.
7434 if(w->misc==1 && w->clk2>256 && w->clk2<272)
7435 direction=oppositeDir[direction];
7436 }
7437
3/4
✓ Branch 0 taken 20603 times.
✓ Branch 1 taken 81 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20603 times.
20684 if(itemtype==itype_brang && get_bit(quest_rules, qr_WRONG_BRANG_TRAIL_DIR)) direction = 0;
7438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20684 times.
20684 zfix x = w->x+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(h*4);
7439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20684 times.
20684 zfix y = w->y+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(v*4)-w->fakez;
7440
5/10
✓ Branch 0 taken 20684 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20684 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20684 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20684 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 20684 times.
✗ Branch 9 not taken.
20684 Lwpns.add(new weapon(x, y, w->z, sparkle_type==wpn3 ? wFSparkle : wSSparkle,sparkle_type,0,direction,itemid,getUID(),false,false,true, 0, sparkle_type));
7441 20684 weapon *w = (weapon*)(Lwpns.spr(Lwpns.Count()-1));
7442 20684 }
7443 190367 }
7444
7445 // For wPhantoms
7446 void HeroClass::addsparkle2(int32_t type1, int32_t type2)
7447 {
7448 if(frame%4) return;
7449
7450 int32_t arrow = -1;
7451
7452 for(int32_t i=0; i<Lwpns.Count(); i++)
7453 {
7454 weapon *w = (weapon*)Lwpns.spr(i);
7455
7456 if(w->id == wPhantom && w->type == type1)
7457 {
7458 arrow = i;
7459 break;
7460 }
7461 }
7462
7463 if(arrow==-1)
7464 {
7465 return;
7466 }
7467
7468 zfix x = (Lwpns.spr(arrow)->x-3)+(zc_oldrand()%7);
7469 zfix y = (Lwpns.spr(arrow)->y-3)+(zc_oldrand()%7)-Lwpns.spr(arrow)->fakez;
7470 Lwpns.add(new weapon(x, y, Lwpns.spr(arrow)->z, wPhantom, type2,0,0,((weapon*)Lwpns.spr(arrow))->parentitem,-1));
7471 }
7472
7473 //cleans up decorations that exit the bounds of the screen for a int32_t time, to prevebt them wrapping around.
7474 3394919 void HeroClass::PhantomsCleanup()
7475 {
7476
1/2
✓ Branch 0 taken 3394919 times.
✗ Branch 1 not taken.
3394919 if(Lwpns.idCount(wPhantom))
7477 {
7478 for(int32_t i=0; i<Lwpns.Count(); i++)
7479 {
7480 weapon *w = ((weapon *)Lwpns.spr(i));
7481 if ( w->id == wPhantom && !w->isScriptGenerated() )
7482 {
7483 if ( w->x < -10000 || w->y > 10000 || w->x < -10000 || w->y > 10000 )
7484 {
7485 Lwpns.remove(w);
7486 }
7487 }
7488 }
7489 }
7490 3394919 }
7491
7492 //Waitframe handler for refilling operations
7493 4434 static void do_refill_waitframe()
7494 {
7495 4434 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,game->should_show_time(),sspUP);
7496
1/2
✓ Branch 0 taken 4434 times.
✗ Branch 1 not taken.
4434 if(get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
7497 {
7498 script_drawing_commands.Clear();
7499 if(DMaps[currdmap].passive_sub_script != 0)
7500 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
7501 if(passive_subscreen_waitdraw && DMaps[currdmap].passive_sub_script != 0 && passive_subscreen_doscript != 0)
7502 {
7503 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
7504 passive_subscreen_waitdraw = false;
7505 }
7506 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
7507 }
7508 4434 advanceframe(true);
7509 4434 }
7510 //Special handler if it's a "fairy revive"
7511 static void do_death_refill_waitframe()
7512 {
7513 //!TODO Run a new script slot each frame here, before calling do_refill_waitframe()
7514 //This script should be able to draw a 'fairy saving the player' animation -Em
7515 do_refill_waitframe();
7516 }
7517
7518 static size_t find_bottle_for_slot(size_t slot, bool unowned=false)
7519 {
7520 int32_t found_unowned = -1;
7521 for(int q = 0; q < MAXITEMS; ++q)
7522 {
7523 if(itemsbuf[q].family == itype_bottle && itemsbuf[q].misc1 == slot)
7524 {
7525 if(game->get_item(q))
7526 return q;
7527 if(unowned)
7528 found_unowned = q;
7529 }
7530 }
7531 return found_unowned;
7532 }
7533
7534 int32_t getPushDir(int32_t flag)
7535 {
7536 switch(flag)
7537 {
7538 case mfPUSHUD: case mfPUSH4: case mfPUSHU: case mfPUSHUDNS:
7539 case mfPUSH4NS: case mfPUSHUNS: case mfPUSHUDINS: case mfPUSH4INS:
7540 case mfPUSHUINS:
7541 return up;
7542 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
7543 return down;
7544 case mfPUSHLR: case mfPUSHL: case mfPUSHLRNS: case mfPUSHLNS:
7545 case mfPUSHLRINS: case mfPUSHLINS:
7546 return left;
7547 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
7548 return right;
7549 }
7550 return -1;
7551 }
7552
7553 // returns true when game over
7554 10102869 bool HeroClass::animate(int32_t)
7555 {
7556 10102869 int32_t lsave=0;
7557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10102869 times.
10102869 if(immortal > 0)
7558 --immortal;
7559 10102869 prompt_combo = 0;
7560
2/2
✓ Branch 0 taken 6707637 times.
✓ Branch 1 taken 3395232 times.
10102869 if (onpassivedmg)
7561 {
7562 6707637 onpassivedmg=false;
7563 6707637 }
7564
1/2
✓ Branch 0 taken 3395232 times.
✗ Branch 1 not taken.
3395232 else if (damageovertimeclk)
7565 {
7566 damageovertimeclk = 0;
7567 }
7568
7569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10102869 times.
10102869 if(cheats_execute_goto)
7570 {
7571 didpit=true;
7572 pitx=x;
7573 pity=y;
7574 dowarp(3,0);
7575 cheats_execute_goto=false;
7576 solid_update(false);
7577 return false;
7578 }
7579
7580
1/2
✓ Branch 0 taken 10102869 times.
✗ Branch 1 not taken.
10102869 if(cheats_execute_light)
7581 {
7582 naturaldark = !naturaldark;
7583 lighting(false, false, pal_litOVERRIDE);//Forcibly set permLit, overriding it's current setting
7584 cheats_execute_light = false;
7585 }
7586
7587
3/4
✓ Branch 0 taken 3395232 times.
✓ Branch 1 taken 6707637 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3395232 times.
10102869 if(action!=climbcovertop&&action!=climbcoverbottom)
7588 {
7589 3395232 climb_cover_x=-1000;
7590 3395232 climb_cover_y=-1000;
7591 3395232 }
7592
7593
1/2
✓ Branch 0 taken 10102869 times.
✗ Branch 1 not taken.
10102869 if(mirror_portal)
7594 {
7595 mirror_portal->animate(0);
7596 if(abs(x - mirror_portal->x) < 12
7597 && abs(y - mirror_portal->y) < 12)
7598 {
7599 if(can_mirror_portal)
7600 {
7601 //Store some values to restore if 'warp fails'
7602 int32_t tLastEntrance = lastentrance,
7603 tLastEntranceDMap = lastentrance_dmap,
7604 tContScr = game->get_continue_scrn(),
7605 tContDMap = game->get_continue_dmap();
7606 int32_t sourcescr = currscr, sourcedmap = currdmap;
7607 zfix tx = x, ty = y, tz = z;
7608 x = mirror_portal->x;
7609 y = mirror_portal->y;
7610
7611 int32_t weff = mirror_portal->weffect,
7612 wsfx = mirror_portal->wsfx;
7613
7614 FFCore.warp_player(wtIWARP, mirror_portal->destdmap, mirror_portal->destscr,
7615 -1, -1, weff, wsfx, 0, -1);
7616
7617 if(mirrorBonk()) //Invalid landing, warp back!
7618 {
7619 action = none; FFCore.setHeroAction(none);
7620 lastentrance = tLastEntrance;
7621 lastentrance_dmap = tLastEntranceDMap;
7622 game->set_continue_scrn(tContScr);
7623 game->set_continue_dmap(tContDMap);
7624 x = tx;
7625 y = ty;
7626 z = tz;
7627 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, weff,
7628 wsfx, 0, -1);
7629 can_mirror_portal = false;
7630 }
7631 else game->clear_portal(); //Remove portal once used
7632 }
7633 }
7634 else can_mirror_portal = true;
7635 }
7636
7637
3/4
✓ Branch 0 taken 3392198 times.
✓ Branch 1 taken 6710671 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3392198 times.
10102869 if(z<=8&&fakez<=8)
7638 {
7639
2/2
✓ Branch 0 taken 42395 times.
✓ Branch 1 taken 3349803 times.
3392198 if (get_bit(quest_rules, qr_GRASS_SENSITIVE))
7640 {
7641 42395 bool g1 = isGrassType(COMBOTYPE(x+4,y+15)), g2 = isGrassType(COMBOTYPE(x+11,y+15)), g3 = isGrassType(COMBOTYPE(x+4,y+9)), g4 = isGrassType(COMBOTYPE(x+11,y+9));
7642
2/2
✓ Branch 0 taken 41531 times.
✓ Branch 1 taken 864 times.
42395 if(get_bit(quest_rules, qr_BUSHESONLAYERS1AND2))
7643 {
7644
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 864 times.
864 g1 = g1 || isGrassType(COMBOTYPEL(1,x+4,y+15)) || isGrassType(COMBOTYPEL(2,x+4,y+15));
7645
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 864 times.
864 g2 = g2 || isGrassType(COMBOTYPEL(1,x+11,y+15)) || isGrassType(COMBOTYPEL(2,x+11,y+15));
7646
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 864 times.
864 g3 = g3 || isGrassType(COMBOTYPEL(1,x+4,y+9)) || isGrassType(COMBOTYPEL(2,x+4,y+9));
7647
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 864 times.
864 g4 = g4 || isGrassType(COMBOTYPEL(1,x+11,y+9)) || isGrassType(COMBOTYPEL(2,x+11,y+9));
7648 864 }
7649
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 42395 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
42395 if(g1 && g2 && g3 && g4)
7650 {
7651 if(decorations.idCount(dTALLGRASS)==0)
7652 {
7653 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0));
7654 }
7655 int32_t thesfx = combobuf[MAPCOMBO(x+8,y+12)].attribytes[3];
7656 if ( thesfx > 0 && !sfx_allocated(thesfx) && action==walking )
7657 sfx(thesfx,pan((int32_t)x));
7658 }
7659 42395 }
7660 else
7661 {
7662 3349803 bool g1 = isGrassType(COMBOTYPE(x,y+15)), g2 = isGrassType(COMBOTYPE(x+15,y+15));
7663
2/2
✓ Branch 0 taken 14221 times.
✓ Branch 1 taken 3335582 times.
3349803 if(get_bit(quest_rules, qr_BUSHESONLAYERS1AND2))
7664 {
7665
2/4
✓ Branch 0 taken 14221 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14221 times.
14221 g1 = g1 || isGrassType(COMBOTYPEL(1,x,y+15)) || isGrassType(COMBOTYPEL(2,x,y+15));
7666
2/4
✓ Branch 0 taken 14221 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14221 times.
14221 g2 = g2 || isGrassType(COMBOTYPEL(1,x+15,y+15)) || isGrassType(COMBOTYPEL(2,x+15,y+15));
7667 14221 }
7668
4/4
✓ Branch 0 taken 41523 times.
✓ Branch 1 taken 3308280 times.
✓ Branch 2 taken 5567 times.
✓ Branch 3 taken 35956 times.
3349803 if(g1 && g2)
7669 {
7670
2/2
✓ Branch 0 taken 35437 times.
✓ Branch 1 taken 519 times.
35956 if(decorations.idCount(dTALLGRASS)==0)
7671 {
7672
3/6
✓ Branch 0 taken 519 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 519 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 519 times.
✗ Branch 5 not taken.
519 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0));
7673 519 }
7674 35956 int32_t thesfx = combobuf[MAPCOMBO(x+8,y+15)].attribytes[3];
7675
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 35956 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35956 if ( thesfx > 0 && !sfx_allocated(thesfx) && action==walking )
7676 sfx(thesfx,pan((int32_t)x));
7677 35956 }
7678 }
7679 3392198 }
7680
7681
2/2
✓ Branch 0 taken 6979466 times.
✓ Branch 1 taken 3123403 times.
10102869 if (get_bit(quest_rules, qr_SHALLOW_SENSITIVE))
7682 {
7683
18/26
✓ Branch 0 taken 268712 times.
✓ Branch 1 taken 6710754 times.
✓ Branch 2 taken 268712 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 267433 times.
✓ Branch 5 taken 1279 times.
✓ Branch 6 taken 267433 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 266729 times.
✓ Branch 9 taken 704 times.
✓ Branch 10 taken 266729 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 266729 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 266729 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 266519 times.
✓ Branch 17 taken 210 times.
✓ Branch 18 taken 266519 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 266497 times.
✓ Branch 21 taken 22 times.
✓ Branch 22 taken 266497 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 266497 times.
6979466 if (z == 0 && fakez == 0 && action != swimming && action != isdiving && action != drowning && action!=lavadrowning && action!=sidedrowning && action!=rafting && action != falling && !IsSideSwim() && !(ladderx+laddery) && !pull_hero && !toogam)
7684 {
7685
2/2
✓ Branch 0 taken 243361 times.
✓ Branch 1 taken 23136 times.
291163 if (iswaterex(FFORCOMBO(x+11,y+15), currmap, currscr, -1, x+11,y+15, false, false, true, true)
7686
2/2
✓ Branch 0 taken 24666 times.
✓ Branch 1 taken 241831 times.
266497 && iswaterex(FFORCOMBO(x+4,y+15), currmap, currscr, -1, x+4,y+15, false, false, true, true)
7687
2/2
✓ Branch 0 taken 23788 times.
✓ Branch 1 taken 878 times.
24666 && iswaterex(FFORCOMBO(x+11,y+9), currmap, currscr, -1, x+11,y+9, false, false, true, true)
7688
2/2
✓ Branch 0 taken 23170 times.
✓ Branch 1 taken 618 times.
23788 && iswaterex(FFORCOMBO(x+4,y+9), currmap, currscr, -1, x+4,y+9, false, false, true, true))
7689 {
7690
2/2
✓ Branch 0 taken 22979 times.
✓ Branch 1 taken 157 times.
23136 if(decorations.idCount(dRIPPLES)==0)
7691 {
7692
3/6
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 157 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 157 times.
✗ Branch 5 not taken.
157 decorations.add(new dRipples(x, y, dRIPPLES, 0));
7693 157 }
7694 23136 int32_t watercheck = iswaterex(FFORCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, false, false, true, true);
7695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23136 times.
23136 if (combobuf[watercheck].usrflags&cflag2)
7696 {
7697 if (!(current_item(combobuf[watercheck].attribytes[2]) > 0 && current_item(combobuf[watercheck].attribytes[2]) >= combobuf[watercheck].attribytes[3]))
7698 {
7699 onpassivedmg = true;
7700 if (!damageovertimeclk)
7701 {
7702 int32_t curhp = game->get_life();
7703 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
7704 else game->set_life(vbound(game->get_life()+combobuf[watercheck].attributes[1]/10000L, 0, game->get_maxlife()));
7705 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
7706 if (game->get_life() < curhp && combobuf[watercheck].usrflags&cflag7)
7707 {
7708 hclk = 48;
7709 hitdir = -1;
7710 action = gothit; FFCore.setHeroAction(gothit);
7711 }
7712 }
7713 if (combobuf[watercheck].attribytes[1] > 0)
7714 {
7715 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
7716 else --damageovertimeclk;
7717 }
7718 else damageovertimeclk = 0;
7719 }
7720 else damageovertimeclk = 0;
7721 }
7722 23136 else damageovertimeclk = 0;
7723 23136 int32_t thesfx = combobuf[watercheck].attribytes[0];
7724
3/4
✓ Branch 0 taken 22806 times.
✓ Branch 1 taken 330 times.
✓ Branch 2 taken 22806 times.
✗ Branch 3 not taken.
23136 if (combobuf[watercheck].type != cSHALLOWWATER || !get_bit(quest_rules, qr_OLD_SHALLOW_SFX))
7725 {
7726 330 thesfx = combobuf[watercheck].attribytes[5];
7727 330 }
7728
5/6
✓ Branch 0 taken 21663 times.
✓ Branch 1 taken 1473 times.
✓ Branch 2 taken 21663 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12270 times.
✓ Branch 5 taken 9393 times.
23136 if ( thesfx > 0 && !sfx_allocated(thesfx) && action==walking )
7729 9393 sfx(thesfx,pan((int32_t)x));
7730 23136 }
7731 266497 }
7732 6979466 }
7733 else
7734 {
7735
7/8
✓ Branch 0 taken 4311 times.
✓ Branch 1 taken 3119092 times.
✓ Branch 2 taken 4156 times.
✓ Branch 3 taken 155 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4156 times.
✓ Branch 6 taken 3119247 times.
✓ Branch 7 taken 4156 times.
3123403 if((COMBOTYPE(x,y+15)==cSHALLOWWATER)&&(COMBOTYPE(x+15,y+15)==cSHALLOWWATER) && z==0 && fakez==0)
7736 {
7737
2/2
✓ Branch 0 taken 4119 times.
✓ Branch 1 taken 37 times.
4156 if(decorations.idCount(dRIPPLES)==0)
7738 {
7739
3/6
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 37 times.
✗ Branch 5 not taken.
37 decorations.add(new dRipples(x, y, dRIPPLES, 0));
7740 37 }
7741 4156 int32_t watercheck = FFORCOMBO(x+7.5,y.getInt()+15);
7742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4156 times.
4156 if (combobuf[watercheck].usrflags&cflag2)
7743 {
7744 if (!(current_item(combobuf[watercheck].attribytes[2]) > 0 && current_item(combobuf[watercheck].attribytes[2]) >= combobuf[watercheck].attribytes[3]))
7745 {
7746 onpassivedmg = true;
7747 if (!damageovertimeclk)
7748 {
7749 int32_t curhp = game->get_life();
7750 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
7751 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
7752 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
7753 }
7754 if (combobuf[watercheck].attribytes[1] > 0)
7755 {
7756 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
7757 else --damageovertimeclk;
7758 }
7759 else damageovertimeclk = 0;
7760 }
7761 else damageovertimeclk = 0;
7762 }
7763 4156 else damageovertimeclk = 0;
7764 4156 int32_t thesfx = combobuf[watercheck].attribytes[0];
7765
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4156 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4156 if ( thesfx > 0 && !sfx_allocated(thesfx) && action==walking )
7766 sfx(thesfx,pan((int32_t)x));
7767 4156 }
7768 }
7769
7770
2/2
✓ Branch 0 taken 10102841 times.
✓ Branch 1 taken 28 times.
10102869 if(stomping)
7771 28 stomping = false;
7772
7773
2/2
✓ Branch 0 taken 10102655 times.
✓ Branch 1 taken 214 times.
10102869 if(getOnSideviewLadder())
7774 {
7775
4/8
✓ Branch 0 taken 214 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 214 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 214 times.
214 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
7776 {
7777 setOnSideviewLadder(false);
7778 }
7779
2/8
✓ Branch 0 taken 214 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 214 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
214 else if(CANFORCEFACEUP)
7780 {
7781 setDir(up);
7782 }
7783 214 }
7784
7785
6/8
✓ Branch 0 taken 3392282 times.
✓ Branch 1 taken 6710587 times.
✓ Branch 2 taken 3391578 times.
✓ Branch 3 taken 704 times.
✓ Branch 4 taken 3391578 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3391578 times.
10102869 if(action!=inwind && action!=drowning && action!=lavadrowning && action!= sidedrowning)
7786 {
7787
2/2
✓ Branch 0 taken 3246961 times.
✓ Branch 1 taken 144617 times.
3391578 if(!get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
7788 {
7789 144617 checkchest(cCHEST);
7790 144617 checkchest(cLOCKEDCHEST);
7791 144617 checkchest(cBOSSCHEST);
7792 144617 }
7793
2/2
✓ Branch 0 taken 3376621 times.
✓ Branch 1 taken 14957 times.
3391578 if(!get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
7794 {
7795 14957 checkchest(cLOCKBLOCK);
7796 14957 checkchest(cBOSSLOCKBLOCK);
7797 14957 }
7798 3391578 }
7799 10102869 checksigns();
7800 10102869 checkgenpush();
7801
7802
4/4
✓ Branch 0 taken 3376800 times.
✓ Branch 1 taken 6726069 times.
✓ Branch 2 taken 805 times.
✓ Branch 3 taken 3375995 times.
10102869 if(isStanding(true) && fall == 0)
7803 {
7804
1/2
✓ Branch 0 taken 3375995 times.
✗ Branch 1 not taken.
3375995 if(extra_jump_count > 0)
7805 extra_jump_count = 0;
7806 3375995 coyotetime = 0;
7807 3375995 }
7808
2/2
✓ Branch 0 taken 6709599 times.
✓ Branch 1 taken 17275 times.
6726874 else if(coyotetime < 65535)
7809 {
7810 17275 ++coyotetime;
7811 17275 }
7812
1/2
✓ Branch 0 taken 10102869 times.
✗ Branch 1 not taken.
10102869 if(can_use_item(itype_hoverboots,i_hoverboots))
7813 {
7814 int32_t hoverid = current_item_id(itype_hoverboots);
7815 if(!(itemsbuf[hoverid].flags & ITEM_FLAG1))
7816 {
7817 if(hoverclk < 0) hoverclk = 0;
7818 hoverflags &= ~HOV_OUT;
7819 }
7820 }
7821 10102869 bool platformfell2 = false;
7822 10102869 int32_t gravity3 = (zinit.gravity2/100);
7823 10102869 int32_t termv = (zinit.terminalv);
7824 10102869 int32_t rocs = getRocsPressed();
7825
2/2
✓ Branch 0 taken 10101802 times.
✓ Branch 1 taken 1067 times.
10102869 if (rocs != -1)
7826 {
7827 1067 itemdata const& itm = itemsbuf[rocs];
7828
1/2
✓ Branch 0 taken 1067 times.
✗ Branch 1 not taken.
1067 if (itm.flags & ITEM_FLAG2)
7829 {
7830 if ((!(itm.flags & ITEM_FLAG3) || fall < 0) &&
7831 (!(itm.flags & ITEM_FLAG4) || fall > 0)) gravity3 = itm.misc3;
7832 }
7833
1/2
✓ Branch 0 taken 1067 times.
✗ Branch 1 not taken.
1067 if (itm.flags & ITEM_FLAG5)
7834 {
7835 termv = itm.misc4;
7836 if (fall > termv) fall = termv;
7837 }
7838 1067 }
7839
2/2
✓ Branch 0 taken 31654 times.
✓ Branch 1 taken 10071215 times.
10102869 if(sideview_mode()) // Sideview gravity
7840 {
7841 //Handle falling through a platform
7842 31654 bool platformfell = false;
7843
4/4
✓ Branch 0 taken 16517 times.
✓ Branch 1 taken 15137 times.
✓ Branch 2 taken 16502 times.
✓ Branch 3 taken 15 times.
31654 if (on_sideview_solid_oldpos(x,y,old_x,old_y,true,3) && !on_sideview_solid_oldpos(x,y,old_x,old_y,false,3))
7844 {
7845
7/8
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 8 times.
15 if (!(!on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && Down())) platformfell = true;
7846 15 y+=1; //Fall down a pixel instantly, through the platform.
7847
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8 times.
15 if(fall < 0) fall = 0;
7848
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8 times.
15 if(jumping < 0) jumping = 0;
7849 15 platformfell2 = true;
7850 15 }
7851 //Unless using old collision, run this check BEFORE moving Hero, to prevent clipping into the ceiling.
7852
2/2
✓ Branch 0 taken 24709 times.
✓ Branch 1 taken 6945 times.
31654 if(!get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON))
7853 {
7854
14/22
✓ Branch 0 taken 6055 times.
✓ Branch 1 taken 890 times.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 890 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 890 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 890 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 889 times.
✓ Branch 12 taken 889 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 889 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 889 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 889 times.
✓ Branch 20 taken 6944 times.
✓ Branch 21 taken 1 times.
7835 if(fall < 0 && (_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE)
7855
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 889 times.
✓ Branch 2 taken 874 times.
✓ Branch 3 taken 15 times.
904 || ((y+(fall/100)<=0) &&
7856 // Extra checks if Smart Screen Scrolling is enabled
7857
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
15 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
7858 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up)))))))
7859 {
7860 1 fall = jumping = 0; // Bumped his head
7861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
7862 y -= y.getInt()%8; //fix coords
7863 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
7864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
7865 {
7866 1 checkdamagecombos(x+4, x+12, y-1, y-1);
7867 1 }
7868 1 }
7869 6945 }
7870 // Fall, unless on a ladder, sideview ladder, rafting, using the hookshot, drowning, sideswimming or cheating.
7871
8/14
✗ Branch 0 not taken.
✓ Branch 1 taken 31654 times.
✓ Branch 2 taken 31654 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31654 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 31654 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 31654 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 31654 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 214 times.
✓ Branch 13 taken 31440 times.
31654 if(!(toogam && Up()) && !drownclk && action!=rafting && !IsSideSwim() && !pull_hero && !((ladderx || laddery) && fall>0) && !getOnSideviewLadder())
7872 {
7873
1/2
✓ Branch 0 taken 31440 times.
✗ Branch 1 not taken.
31440 int32_t ydiff = fall/(spins && fall<0 ? 200:100);
7874 //zprint2("ydif is: %d\n", ydiff);
7875 //zprint2("ydif is: %d\n", (int32_t)fall);
7876 31440 falling_oldy = y; // Stomp Boots-related variable
7877
5/8
✓ Branch 0 taken 9520 times.
✓ Branch 1 taken 21920 times.
✓ Branch 2 taken 9520 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9520 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 31440 times.
✗ Branch 7 not taken.
31440 if(fall > 0 && (checkSVLadderPlatform(x+4,y+ydiff+15)||checkSVLadderPlatform(x+12,y+ydiff+15)) && (((y.getInt()+ydiff+15)&0xF0)!=((y.getInt()+15)&0xF0)) && !platform_fallthrough())
7878 {
7879 ydiff -= (y.getInt()+ydiff)%16;
7880 }
7881
4/4
✓ Branch 0 taken 12500 times.
✓ Branch 1 taken 18940 times.
✓ Branch 2 taken 10863 times.
✓ Branch 3 taken 1637 times.
31440 if(ydiff && !get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
7882 {
7883
2/2
✓ Branch 0 taken 873 times.
✓ Branch 1 taken 764 times.
1637 if(ydiff > 0)
7884 {
7885
2/2
✓ Branch 0 taken 831 times.
✓ Branch 1 taken 1607 times.
2438 for(auto q = 0; q < ydiff; ++q)
7886 {
7887
2/2
✓ Branch 0 taken 1565 times.
✓ Branch 1 taken 42 times.
1607 if(on_sideview_solid_oldpos(x,y+q,old_x,old_y))
7888 {
7889 42 ydiff = q;
7890 42 break;
7891 }
7892 1565 }
7893 873 }
7894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 764 times.
764 else if(ydiff < 0)
7895 {
7896
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 1492 times.
2256 for(auto q = 0; q > ydiff; --q)
7897 {
7898
1/2
✓ Branch 0 taken 1492 times.
✗ Branch 1 not taken.
2984 if(_walkflag(x+4,y+(bigHitbox?0:8)+q-1,1)
7899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1492 times.
1492 || _walkflag(x+12,y+(bigHitbox?0:8)+q,1))
7900 {
7901 ydiff = q;
7902 break;
7903 }
7904 1492 }
7905 764 }
7906 1637 }
7907 31440 y+=ydiff;
7908 31440 hs_starty+=ydiff;
7909
7910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31440 times.
31440 for(int32_t j=0; j<chainlinks.Count(); j++)
7911 {
7912 chainlinks.spr(j)->y+=ydiff;
7913 }
7914
7915
1/2
✓ Branch 0 taken 31440 times.
✗ Branch 1 not taken.
31440 if(Lwpns.idFirst(wHookshot)>-1)
7916 {
7917 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=ydiff;
7918 }
7919
7920
1/2
✓ Branch 0 taken 31440 times.
✗ Branch 1 not taken.
31440 if(Lwpns.idFirst(wHSHandle)>-1)
7921 {
7922 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=ydiff;
7923 }
7924 31440 }
7925
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 214 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
214 else if(IsSideSwim() && action != sidewaterhold1 && action != sidewaterhold2 && action != sideswimcasting && action != sideswimfreeze)
7926 {
7927 fall = hoverclk = jumping = 0;
7928 inair = false;
7929 hoverflags = 0;
7930 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
7931 {
7932 WalkflagInfo info;
7933 if (game->get_watergrav()<0)
7934 {
7935 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
7936 execute(info);
7937 }
7938 else
7939 {
7940 info = walkflag(x,y+15+2,2,down);
7941 execute(info);
7942 }
7943 if(!info.isUnwalkable() && (game->get_watergrav() > 0 || iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)-2), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false))) y+=(game->get_watergrav()/10000.0);
7944 }
7945 }
7946 // Stop hovering/falling if you land on something.
7947 31654 bool needFall = false;
7948
7/8
✓ Branch 0 taken 15058 times.
✓ Branch 1 taken 16596 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31654 times.
✓ Branch 4 taken 16810 times.
✓ Branch 5 taken 14844 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 16797 times.
31654 if((on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder()) && !(pull_hero && dir==down) && action!=rafting && !platformfell2)
7949 {
7950 16797 stop_item_sfx(itype_hoverboots);
7951
1/2
✓ Branch 0 taken 11903 times.
✗ Branch 1 not taken.
28700 if(get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE)
7952
2/2
✓ Branch 0 taken 12665 times.
✓ Branch 1 taken 4132 times.
16797 && !getOnSideviewLadder()
7953
3/4
✓ Branch 0 taken 12665 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11903 times.
✓ Branch 3 taken 762 times.
12665 && (fall > 0 || get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON)))
7954 12665 y-=(int32_t)y%8; //fix position
7955 16797 fall = hoverclk = jumping = 0;
7956 16797 inair = false;
7957 16797 hoverflags = 0;
7958
7959
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16797 if(y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) // Landed on the bottommost screen.
7960 y = 160;
7961 16797 }
7962 // Stop hovering if you press down.
7963
3/6
✓ Branch 0 taken 14857 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14857 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14857 times.
✗ Branch 5 not taken.
14857 else if((hoverclk>0 || ladderx || laddery) && DrunkDown())
7964 {
7965 stop_item_sfx(itype_hoverboots);
7966 hoverclk = -hoverclk;
7967 reset_ladder();
7968 fall = gravity3;
7969 inair = false;
7970 }
7971
9/12
✓ Branch 0 taken 14857 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1372 times.
✓ Branch 3 taken 13485 times.
✓ Branch 4 taken 1037 times.
✓ Branch 5 taken 335 times.
✓ Branch 6 taken 1029 times.
✓ Branch 7 taken 8 times.
✓ Branch 8 taken 1029 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1029 times.
14857 else if (hoverclk < 1 && !inair && fall == 0 && !platformfell && !IsSideSwim() && justmoved <= 0)
7972 {
7973 1029 zfix my = y + 4;
7974 1029 needFall = true;
7975
2/2
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 1561 times.
1695 for (zfix ty = y+1; ty < my; ++ty)
7976 {
7977 //if (on_sideview_solid_oldpos(x, ty,old_x,old_y, false, 1)) break;
7978
2/2
✓ Branch 0 taken 666 times.
✓ Branch 1 taken 895 times.
1561 if (on_sideview_solid_oldpos(x, ty,old_x,old_y, false, 0))
7979 {
7980 895 y = ty;
7981
2/2
✓ Branch 0 taken 149 times.
✓ Branch 1 taken 746 times.
895 if (check_new_slope(x, ty + 1, 16, 16, old_x, old_y, false) < 0)
7982 {
7983
2/2
✓ Branch 0 taken 737 times.
✓ Branch 1 taken 9 times.
746 if(!slopeid)
7984 9 slopeid = get_new_slope(x, ty + 1, 16, 16, old_x, old_y).get_info().slope();
7985 746 onplatid = 5;
7986 746 }
7987 895 needFall = false;
7988 895 break;
7989 }
7990 666 }
7991 1029 }
7992 13828 else needFall = true;
7993 // Continue falling.
7994
7995
4/4
✓ Branch 0 taken 29151 times.
✓ Branch 1 taken 2503 times.
✓ Branch 2 taken 17692 times.
✓ Branch 3 taken 11459 times.
31654 if(fall <= termv && needFall)
7996 {
7997 11459 inair = true;
7998
3/4
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 11264 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 195 times.
11459 if(fall != 0 || hoverclk>0)
7999 11264 jumping++;
8000
8001 // Bump head if: hit a solid combo from beneath, or hit a solid combo in the screen above this one.
8002
2/2
✓ Branch 0 taken 9536 times.
✓ Branch 1 taken 1923 times.
11459 if(get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON))
8003 {
8004
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9536 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9536 times.
✓ Branch 4 taken 9426 times.
✓ Branch 5 taken 110 times.
19072 if((_walkflag(x+4,y-(bigHitbox?9:1),0,SWITCHBLOCK_STATE)
8005
4/4
✓ Branch 0 taken 8933 times.
✓ Branch 1 taken 603 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 8908 times.
9536 || (y<=(bigHitbox?9:1) &&
8006 // Extra checks if Smart Screen Scrolling is enabled
8007
2/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8008 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
8009
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
603 && fall < 0)
8010 {
8011 110 fall = jumping = 0; // Bumped his head
8012
8013 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8015 {
8016 110 checkdamagecombos(x+4, x+12, y-1, y-1);
8017 110 }
8018 110 }
8019 9536 }
8020 else
8021 {
8022
8/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1923 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1923 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1923 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1923 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1923 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1923 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1923 times.
✓ Branch 14 taken 1923 times.
✗ Branch 15 not taken.
3846 if((_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE)
8023
3/4
✓ Branch 0 taken 1923 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 1904 times.
1923 || ((y<=0) &&
8024 // Extra checks if Smart Screen Scrolling is enabled
8025
2/6
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
19 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8026 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
8027 && fall < 0)
8028 {
8029 fall = jumping = 0; // Bumped his head
8030 y -= y.getInt()%8; //fix coords
8031 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8032 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8033 {
8034 checkdamagecombos(x+4, x+12, y-1, y-1);
8035 }
8036 }
8037 }
8038
8039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11459 times.
11459 if(hoverclk > 0)
8040 {
8041 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8042 {
8043 --hoverclk;
8044 }
8045
8046 if(!hoverclk && !ladderx && !laddery)
8047 {
8048 fall += gravity3;
8049 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8050 }
8051 }
8052
5/12
✓ Branch 0 taken 6540 times.
✓ Branch 1 taken 4919 times.
✓ Branch 2 taken 377 times.
✓ Branch 3 taken 6163 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 377 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
11459 else if(fall+gravity3 > 0 && fall<=0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
8053 {
8054 int32_t itemid = current_item_id(itype_hoverboots);
8055 if(hoverclk < 0)
8056 hoverclk = -hoverclk;
8057 else
8058 {
8059 fall = jumping = 0;
8060 if(itemsbuf[itemid].misc1)
8061 hoverclk = itemsbuf[itemid].misc1;
8062 else
8063 {
8064 hoverclk = 1;
8065 hoverflags |= HOV_INF;
8066 }
8067
8068
8069 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
8070 }
8071 if(itemsbuf[itemid].wpn)
8072 decorations.add(new dHover(x, y, dHOVER, 0));
8073 }
8074
4/8
✓ Branch 0 taken 11459 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11459 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11459 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 11459 times.
11459 else if(!ladderx && !laddery && !getOnSideviewLadder() && !IsSideSwim())
8075 {
8076 11459 fall += gravity3;
8077
8078 11459 }
8079 11459 }
8080 31654 }
8081 else // Topdown gravity
8082 {
8083
4/4
✓ Branch 0 taken 6707638 times.
✓ Branch 1 taken 3363577 times.
✓ Branch 2 taken 3362729 times.
✓ Branch 3 taken 848 times.
10071215 if (!(moveflags & FLAG_NO_FAKE_Z)) fakez-=fakefall/(spins && fakefall>0 ? 200:100);
8084
4/4
✓ Branch 0 taken 6707638 times.
✓ Branch 1 taken 3363577 times.
✓ Branch 2 taken 3362729 times.
✓ Branch 3 taken 848 times.
10071215 if (!(moveflags & FLAG_NO_REAL_Z)) z-=fall/(spins && fall>0 ? 200:100);
8085
4/4
✓ Branch 0 taken 3360309 times.
✓ Branch 1 taken 6710906 times.
✓ Branch 2 taken 6714174 times.
✓ Branch 3 taken 10074483 times.
10071215 if(z>0||fakez>0)
8086 {
8087
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13425080 switch(action)
8088 {
8089 case swimming:
8090 {
8091 diveclk=0;
8092 action=walking; FFCore.setHeroAction(walking);
8093
8094 break;
8095 }
8096 case waterhold1:
8097 {
8098 action=landhold1; FFCore.setHeroAction(landhold1);
8099 break;
8100 }
8101
8102 case waterhold2:
8103 {
8104 action=landhold2; FFCore.setHeroAction(landhold2);
8105 break;
8106 }
8107
8108 default:
8109 3268 break;
8110 }
8111 3268 }
8112
8113
2/2
✓ Branch 0 taken 2813 times.
✓ Branch 1 taken 10077751 times.
10080564 for(int32_t j=0; j<chainlinks.Count(); j++)
8114 {
8115 2813 chainlinks.spr(j)->z=z;
8116 2813 chainlinks.spr(j)->fakez=fakez;
8117 2813 }
8118
8119
2/2
✓ Branch 0 taken 10077022 times.
✓ Branch 1 taken 729 times.
10077751 if(Lwpns.idFirst(wHookshot)>-1)
8120 {
8121 729 Lwpns.spr(Lwpns.idFirst(wHookshot))->z=z;
8122 729 Lwpns.spr(Lwpns.idFirst(wHookshot))->fakez=fakez;
8123 729 }
8124
8125
2/2
✓ Branch 0 taken 10076989 times.
✓ Branch 1 taken 762 times.
10077751 if(Lwpns.idFirst(wHSHandle)>-1)
8126 {
8127 762 Lwpns.spr(Lwpns.idFirst(wHSHandle))->z=z;
8128 762 Lwpns.spr(Lwpns.idFirst(wHSHandle))->fakez=fakez;
8129 762 }
8130
8131
3/4
✓ Branch 0 taken 3360309 times.
✓ Branch 1 taken 6717442 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3360309 times.
10077751 if(z<=0&&!(moveflags & FLAG_NO_REAL_Z))
8132 {
8133
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3360309 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3360309 if (fakez <= 0 || (moveflags & FLAG_NO_FAKE_Z))
8134 {
8135
2/2
✓ Branch 0 taken 3360281 times.
✓ Branch 1 taken 28 times.
3360309 if(fall > 0)
8136 {
8137
6/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✓ Branch 7 taken 6 times.
28 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8138 6 sfx(WAV_ZN1SPLASH,x.getInt());
8139
8140 28 stomping = true;
8141 28 }
8142 3360309 }
8143 3360309 z = fall = 0;
8144
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3360309 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3360309 if (fakez <= 0 || (moveflags & FLAG_NO_FAKE_Z))
8145 {
8146 3360309 jumping = 0;
8147
2/2
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 3360074 times.
3360309 if(check_pitslide(true) == -1)
8148 {
8149 3360074 hoverclk = 0;
8150 3360074 hoverflags = 0;
8151 3360074 }
8152
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 235 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
235 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8153 {
8154 if(!--hoverclk)
8155 {
8156 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8157 }
8158 }
8159 3360309 }
8160 3360309 }
8161
3/4
✓ Branch 0 taken 3363577 times.
✓ Branch 1 taken 6714174 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3363577 times.
10077751 if(fakez<=0&&!(moveflags & FLAG_NO_FAKE_Z))
8162 {
8163
3/4
✓ Branch 0 taken 3268 times.
✓ Branch 1 taken 3360309 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3268 times.
3363577 if (z <= 0 || (moveflags & FLAG_NO_REAL_Z))
8164 {
8165
1/2
✓ Branch 0 taken 3360309 times.
✗ Branch 1 not taken.
3360309 if(fakefall > 0)
8166 {
8167 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8168 sfx(WAV_ZN1SPLASH,x.getInt());
8169
8170 stomping = true;
8171 }
8172 3360309 }
8173 3363577 fakez = fakefall = 0;
8174
3/4
✓ Branch 0 taken 3268 times.
✓ Branch 1 taken 3360309 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3268 times.
3363577 if (z <= 0 || (moveflags & FLAG_NO_REAL_Z))
8175 {
8176 3360309 jumping = 0;
8177
2/2
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 3360074 times.
3360309 if(check_pitslide(true) == -1)
8178 {
8179 3360074 hoverclk = 0;
8180 3360074 hoverflags = 0;
8181 3360074 }
8182
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 235 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
235 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8183 {
8184 if(!--hoverclk)
8185 {
8186 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8187 }
8188 }
8189 3360309 }
8190 3363577 }
8191
8/10
✓ Branch 0 taken 3363554 times.
✓ Branch 1 taken 6714197 times.
✓ Branch 2 taken 3363554 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3357087 times.
✓ Branch 5 taken 6467 times.
✓ Branch 6 taken 3360332 times.
✓ Branch 7 taken 3360332 times.
✓ Branch 8 taken 3360332 times.
✗ Branch 9 not taken.
10077751 if(fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z>0 || fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0)
8192 {
8193
4/6
✓ Branch 0 taken 2715 times.
✓ Branch 1 taken 530 times.
✓ Branch 2 taken 2715 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2715 times.
6717419 if(fall != 0 || fakefall != 0 || hoverclk>0)
8194 530 jumping++;
8195
8196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3245 times.
3245 if(hoverclk > 0)
8197 {
8198 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8199 {
8200 --hoverclk;
8201 }
8202
8203 if(!hoverclk)
8204 {
8205 if (fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z > 0) fall += gravity3;
8206 if (fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0) fakefall += gravity3;
8207 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8208 }
8209 }
8210
9/16
✓ Branch 0 taken 3057 times.
✓ Branch 1 taken 188 times.
✓ Branch 2 taken 2725 times.
✓ Branch 3 taken 332 times.
✓ Branch 4 taken 2725 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 520 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 520 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 520 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 3245 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
3245 else if(((fall+(int32_t)(zinit.gravity2 / 100) > 0 && fall<=0 && !(moveflags & FLAG_NO_REAL_Z) && z > 0) || (fakefall+gravity3 > 0 && fakefall<=0 && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0)) && can_use_item(itype_hoverboots,i_hoverboots) && !(hoverflags & HOV_OUT))
8211 {
8212 if(hoverclk < 0)
8213 hoverclk = -hoverclk;
8214 else
8215 {
8216 fall = 0;
8217 fakefall = 0;
8218 int32_t itemid = current_item_id(itype_hoverboots);
8219 if(itemsbuf[itemid].misc1)
8220 hoverclk = itemsbuf[itemid].misc1;
8221 else
8222 {
8223 hoverclk = 1;
8224 hoverflags |= HOV_INF;
8225 }
8226 sfx(itemsbuf[current_item_id(itype_hoverboots)].usesound,pan(x.getInt()));
8227 }
8228 decorations.add(new dHover(x, y, dHOVER, 0));
8229 }
8230 else
8231 {
8232
3/6
✓ Branch 0 taken 3245 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3245 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3245 times.
3245 if (fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z > 0) fall += gravity3;
8233
3/6
✓ Branch 0 taken 3245 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3245 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3245 times.
✗ Branch 5 not taken.
3245 if (fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0) fakefall += gravity3;
8234 }
8235 3245 }
8236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3363577 times.
3363577 if (fakez<0) fakez = 0;
8237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3363577 times.
3363577 if (z<0) z = 0;
8238 }
8239
8240
1/2
✓ Branch 0 taken 3395231 times.
✗ Branch 1 not taken.
3395231 if(drunkclk)
8241 {
8242 --drunkclk;
8243 }
8244
8245
1/2
✓ Branch 0 taken 3395231 times.
✗ Branch 1 not taken.
3395231 if(lstunclock > 0)
8246 {
8247 // also cancel Hero's attack
8248 attackclk = 0;
8249
8250 if( FFCore.getHeroAction() != stunned )
8251 {
8252 tempaction=action; //update so future checks won't do this
8253 //action=freeze; //setting this makes the player invincible while stunned -V
8254 FFCore.setHeroAction(stunned);
8255 }
8256 --lstunclock;
8257 }
8258 //if the stun action is still set in FFCore, but he isn't stunned, then the timer reached 0
8259 //, so we unfreeze him here, and return him to the action that he had when he was stunned.
8260
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3395231 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3395231 if ( FFCore.getHeroAction() == stunned && !lstunclock )
8261 {
8262 action=tempaction; FFCore.setHeroAction(tempaction);
8263 //zprint("Unfreezing hero to action: %d\n", (int32_t)tempaction);
8264 //action=none; FFCore.setHeroAction(none);
8265 }
8266
8267
1/2
✓ Branch 0 taken 3395231 times.
✗ Branch 1 not taken.
3395231 if( lbunnyclock > 0 )
8268 {
8269 --lbunnyclock;
8270 }
8271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3395231 times.
3395231 if(DMaps[currdmap].flags&dmfBUNNYIFNOPEARL)
8272 {
8273 int32_t itemid = current_item_id(itype_pearl);
8274 if(itemid > -1)
8275 {
8276 if(lbunnyclock == -1) //cure dmap-caused bunny effect
8277 lbunnyclock = 0;
8278 }
8279 else if(lbunnyclock > -1) //No pearl, force into bunny mode
8280 {
8281 lbunnyclock = -1;
8282 }
8283 }
8284
1/2
✓ Branch 0 taken 3395231 times.
✗ Branch 1 not taken.
3395231 else if(lbunnyclock == -1) //dmap-caused bunny effect
8285 {
8286 lbunnyclock = 0;
8287 }
8288
8289
12/16
✓ Branch 0 taken 3390807 times.
✓ Branch 1 taken 4424 times.
✓ Branch 2 taken 3119006 times.
✓ Branch 3 taken 271801 times.
✓ Branch 4 taken 3119006 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1206 times.
✓ Branch 7 taken 3117800 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1206 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 3117197 times.
✓ Branch 13 taken 1809 times.
✓ Branch 14 taken 30192 times.
✓ Branch 15 taken 3086411 times.
3395231 if(!is_on_conveyor && !(diagonalMovement||NO_GRIDLOCK) && (fall==0 || fakefall==0 || z>0 || fakez>0) && charging==0 && spins<=5
8290
2/2
✓ Branch 0 taken 3116603 times.
✓ Branch 1 taken 594 times.
3117197 && action != gothit)
8291 {
8292
2/3
✓ Branch 0 taken 1371156 times.
✓ Branch 1 taken 1715255 times.
✗ Branch 2 not taken.
3086411 switch(dir)
8293 {
8294 case up:
8295 case down:
8296 1371156 x=(x.getInt()+4)&0xFFF8;
8297 1371156 break;
8298
8299 case left:
8300 case right:
8301 1715255 y=(y.getInt()+4)&0xFFF8;
8302 1715255 break;
8303 }
8304 3086411 }
8305
8306
4/4
✓ Branch 0 taken 76971 times.
✓ Branch 1 taken 3318260 times.
✓ Branch 2 taken 56861 times.
✓ Branch 3 taken 20110 times.
3395231 if((watch==true) && clockclk)
8307 {
8308 20110 --clockclk;
8309
8310
2/2
✓ Branch 0 taken 20054 times.
✓ Branch 1 taken 56 times.
20110 if(!clockclk)
8311 {
8312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(cheat_superman==false)
8313 {
8314 56 setClock(false);
8315 56 }
8316
8317 56 watch=false;
8318
8319
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 56 times.
28728 for(int32_t i=0; i<eMAXGUYS; i++)
8320 {
8321
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 28672 times.
28676 for(int32_t zoras=0; zoras<clock_zoras[i]; zoras++)
8322 {
8323 4 addenemy(0,0,i,0);
8324 4 }
8325 28672 }
8326 56 }
8327 20110 }
8328
8329
3/4
✓ Branch 0 taken 3394469 times.
✓ Branch 1 taken 762 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3394469 times.
3395231 if(hookshot_frozen || switch_hooked)
8330 {
8331
3/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 729 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
762 if(hookshot_used || switch_hooked)
8332 {
8333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 729 times.
729 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
8334 729 else {action=freeze; FFCore.setHeroAction(freeze);} //could be LA_HOOKSHOT for FFCore. -Z
8335
8336
3/4
✓ Branch 0 taken 584 times.
✓ Branch 1 taken 145 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 584 times.
729 if(pull_hero || switch_hooked)
8337 {
8338
2/4
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145 times.
145 if(hs_switcher || switch_hooked)
8339 {
8340 hs_fix = false;
8341 if(switchhookclk)
8342 {
8343 --switchhookclk;
8344 if(switchhookclk==switchhookmaxtime/2) //Perform swaps
8345 {
8346 if(switchhook_cost_item > -1 && !checkmagiccost(switchhook_cost_item))
8347 reset_hookshot();
8348 else
8349 {
8350 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
8351 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
8352
8353 if(hooked_combopos > -1) //Switching combos
8354 {
8355 uint16_t targpos = hooked_combopos, plpos = COMBOPOS(x+8,y+8);
8356 if(targpos < 176 && plpos < 176 && hooked_layerbits)
8357 {
8358 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
8359 for(int q = max_layer; q > -1; --q)
8360 {
8361 if(!(hooked_layerbits & (1<<q)))
8362 continue; //non-switching layer
8363 mapscr* scr = FFCore.tempScreens[q];
8364 newcombo const& cmb = combobuf[scr->data[targpos]];
8365 int32_t srcfl = scr->sflag[targpos];
8366 newcombo const& comb2 = combobuf[scr->data[plpos]];
8367 int32_t c = scr->data[plpos], cs = scr->cset[plpos], fl = scr->sflag[plpos];
8368 //{Check push status
8369 bool isFakePush = false;
8370 if(cmb.type == cSWITCHHOOK)
8371 {
8372 if(cmb.usrflags&cflag7) //counts as 'pushblock'
8373 isFakePush = true;
8374 }
8375 bool isPush = isFakePush;
8376 if(!isPush) switch(srcfl)
8377 {
8378 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8379 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8380 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8381 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8382 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8383 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8384 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8385 isPush = true;
8386 }
8387 if(!isPush) switch(cmb.flag)
8388 {
8389 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8390 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8391 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8392 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8393 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8394 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8395 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8396 isPush = true;
8397 }
8398 if(srcfl==mfPUSHED) isPush = false;
8399 //}
8400 if(cmb.type == cSWITCHHOOK) //custom flags and such
8401 {
8402 if(cmb.usrflags&cflag3) //Breaks on swap
8403 {
8404 int32_t it = -1;
8405 int32_t thedropset = -1;
8406 if(cmb.usrflags&cflag4) //drop item
8407 {
8408 if(cmb.usrflags&cflag5)
8409 it = cmb.attribytes[2];
8410 else
8411 {
8412 it = select_dropitem(cmb.attribytes[2]);
8413 thedropset = cmb.attribytes[2];
8414 }
8415 }
8416
8417 breakable* br = new breakable(x, y, zfix(0),
8418 cmb, scr->cset[targpos], it, thedropset, cmb.attribytes[2],
8419 cmb.attribytes[1] ? -1 : 0, cmb.attribytes[1], switchhookclk);
8420 br->switch_hooked = true;
8421 decorations.add(br);
8422 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
8423 hooked_undercombos[q] = -1;
8424
8425 if(cmb.usrflags&cflag6)
8426 {
8427 scr->data[targpos]++;
8428 }
8429 else
8430 {
8431 scr->data[targpos] = scr->undercombo;
8432 scr->cset[targpos] = scr->undercset;
8433 if(cmb.usrflags&cflag2)
8434 scr->sflag[targpos] = 0;
8435 }
8436 }
8437 else if(isPush)
8438 {
8439 //Simulate a block clicking into place
8440 movingblock mtemp;
8441 mtemp.clear();
8442 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
8443 mtemp.dir = getPushDir(scr->sflag[targpos]);
8444 if(mtemp.dir < 0)
8445 mtemp.dir = getPushDir(cmb.flag);
8446 mtemp.clk = 1;
8447 if(isFakePush)
8448 mtemp.force_many = true;
8449 mtemp.animate(0);
8450 if((mtemp.bhole || mtemp.trigger)
8451 && (fl == mfBLOCKTRIGGER || fl == mfBLOCKHOLE
8452 || comb2.flag == mfBLOCKTRIGGER
8453 || comb2.flag == mfBLOCKHOLE))
8454 {
8455 scr->data[targpos] = scr->undercombo;
8456 scr->cset[targpos] = scr->undercset;
8457 scr->sflag[targpos] = 0;
8458 }
8459 else
8460 {
8461 scr->data[targpos] = c;
8462 scr->cset[targpos] = cs;
8463 if(cmb.usrflags&cflag2)
8464 scr->sflag[targpos] = fl;
8465 else
8466 scr->sflag[targpos] = 0;
8467 }
8468 }
8469 else
8470 {
8471 scr->data[plpos] = scr->data[targpos];
8472 scr->cset[plpos] = scr->cset[targpos];
8473 if(cmb.usrflags&cflag2)
8474 scr->sflag[plpos] = scr->sflag[targpos];
8475 scr->data[targpos] = c;
8476 scr->cset[targpos] = cs;
8477 if(cmb.usrflags&cflag2)
8478 scr->sflag[targpos] = fl;
8479 }
8480 }
8481 else if(isCuttableType(cmb.type)) //Break and drop effects
8482 {
8483 int32_t breakcs = scr->cset[targpos];
8484 if(isCuttableNextType(cmb.type)) //next instead of undercmb
8485 {
8486 scr->data[targpos]++;
8487 }
8488 else
8489 {
8490 scr->data[targpos] = scr->undercombo;
8491 scr->cset[targpos] = scr->undercset;
8492 scr->sflag[targpos] = 0;
8493 }
8494
8495 int32_t it = -1;
8496 int32_t thedropset = -1;
8497 if(isCuttableItemType(cmb.type)) //Drop an item
8498 {
8499 if ( (cmb.usrflags&cflag2) )
8500 {
8501 if(cmb.usrflags&cflag11)
8502 it = cmb.attribytes[1];
8503 else
8504 {
8505 it = select_dropitem(cmb.attribytes[1]);
8506 thedropset = cmb.attribytes[1];
8507 }
8508 }
8509 else
8510 {
8511 it = select_dropitem(12);
8512 thedropset = 12;
8513 }
8514 }
8515
8516 byte breaksfx = 0;
8517 if(get_bit(quest_rules,qr_MORESOUNDS)) //SFX
8518 {
8519 if (cmb.usrflags&cflag3)
8520 {
8521 breaksfx = cmb.attribytes[2];
8522 }
8523 else if(isBushType(cmb.type)
8524 || isFlowersType(cmb.type)
8525 || isGrassType(cmb.type))
8526 {
8527 breaksfx = QMisc.miscsfx[sfxBUSHGRASS];
8528 }
8529 }
8530
8531 //Clipping sprite
8532 int16_t decotype = (cmb.usrflags & cflag1) ?
8533 ((cmb.usrflags & cflag10)
8534 ? (cmb.attribytes[0])
8535 : (-1))
8536 : (0);
8537 if(decotype > 3) decotype = 0;
8538 if(!decotype)
8539 decotype = (isBushType(cmb.type) ? 1
8540 : (isFlowersType(cmb.type) ? 2
8541 : (isGrassType(cmb.type) ? 3
8542 : ((cmb.usrflags & cflag1) ? -1
8543 : -2))));
8544
8545 breakable* br = new breakable(x, y, zfix(0),
8546 cmb, breakcs, it, thedropset, breaksfx,
8547 decotype, cmb.attribytes[0], switchhookclk);
8548 br->switch_hooked = true;
8549 decorations.add(br);
8550 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
8551 hooked_undercombos[q] = -1;
8552 }
8553 else //Unknown type, just swap combos.
8554 {
8555 if(isPush)
8556 {
8557 //Simulate a block clicking into place
8558 movingblock mtemp;
8559 mtemp.clear();
8560 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
8561 mtemp.dir = getPushDir(scr->sflag[targpos]);
8562 if(mtemp.dir < 0)
8563 mtemp.dir = getPushDir(cmb.flag);
8564 mtemp.clk = 1;
8565 mtemp.animate(0);
8566 if(mtemp.bhole || mtemp.trigger)
8567 {
8568 scr->data[targpos] = scr->undercombo;
8569 scr->cset[targpos] = scr->undercset;
8570 scr->sflag[targpos] = 0;
8571 }
8572 else
8573 {
8574 scr->data[targpos] = c;
8575 scr->cset[targpos] = cs;
8576 scr->sflag[targpos] = 0;
8577 }
8578 }
8579 else
8580 {
8581 scr->data[plpos] = scr->data[targpos];
8582 scr->cset[plpos] = scr->cset[targpos];
8583 scr->data[targpos] = c;
8584 scr->cset[targpos] = cs;
8585 }
8586 }
8587 }
8588 if(switchhook_cost_item > -1)
8589 paymagiccost(switchhook_cost_item);
8590 zfix tx = x, ty = y;
8591 //Position the player at the combo
8592 x = COMBOX(targpos);
8593 y = COMBOY(targpos);
8594 dir = oppositeDir[dir];
8595 if(w && hw)
8596 {
8597 //Calculate chain shift
8598 zfix dx = (x-tx);
8599 zfix dy = (y-ty);
8600 if(w->dir < 4)
8601 {
8602 if(w->dir & 2)
8603 dx = 0;
8604 else dy = 0;
8605 }
8606 //Position the hook head at the handle
8607 w->x = hw->x + dx;
8608 w->y = hw->y + dy;
8609 w->dir = oppositeDir[w->dir];
8610 w->doAutoRotate(true);
8611 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
8612 w->flip ^= hflip;
8613 //Position the handle appropriately
8614 hw->x = x-(hw->x-tx);
8615 hw->y = y-(hw->y-ty);
8616 hw->dir = oppositeDir[hw->dir];
8617 hw->doAutoRotate(true);
8618 hw->flip ^= hflip;
8619 //Move chains
8620 for(int32_t j=0; j<chainlinks.Count(); j++)
8621 {
8622 chainlinks.spr(j)->x += dx;
8623 chainlinks.spr(j)->y += dy;
8624 }
8625 }
8626 hooked_combopos = plpos; //flip positions
8627 }
8628 else reset_hookshot();
8629 }
8630 else if(switching_object) //Switching an object
8631 {
8632 if(switchhook_cost_item > -1)
8633 paymagiccost(switchhook_cost_item);
8634 zfix tx = x, ty = y;
8635 //Position the player at the object
8636 x = switching_object->x;
8637 y = switching_object->y;
8638 dir = oppositeDir[dir];
8639 //Position the object at the player
8640 switching_object->x = tx;
8641 switching_object->y = ty;
8642 if(switching_object->dir == dir || switching_object->dir == oppositeDir[dir])
8643 switching_object->dir = oppositeDir[switching_object->dir];
8644 solid_update(false);
8645 switching_object->solid_update(false);
8646 if(item* it = dynamic_cast<item*>(switching_object))
8647 {
8648 if(itemsbuf[it->id].family == itype_fairy && itemsbuf[it->id].misc3)
8649 {
8650 movefairynew2(it->x, it->y, *it);
8651 }
8652 }
8653 if(w && hw) //!TODO No fucking clue if diagonals work
8654 {
8655 //Calculate chain shift
8656 zfix dx = (x-tx);
8657 zfix dy = (y-ty);
8658 if(w->dir < 4)
8659 {
8660 if(w->dir & 2)
8661 dx = 0;
8662 else dy = 0;
8663 }
8664 //Position the hook head at the handle
8665 w->x = hw->x + dx;
8666 w->y = hw->y + dy;
8667 w->dir = oppositeDir[w->dir];
8668 w->doAutoRotate(true);
8669 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
8670 w->flip ^= hflip;
8671 w->solid_update(false);
8672 //Position the handle appropriately
8673 hw->x = x-(hw->x-tx);
8674 hw->y = y-(hw->y-ty);
8675 hw->dir = oppositeDir[hw->dir];
8676 hw->doAutoRotate(true);
8677 hw->flip ^= hflip;
8678 hw->solid_update(false);
8679 //Move chains
8680 for(int32_t j=0; j<chainlinks.Count(); j++)
8681 {
8682 chainlinks.spr(j)->x += dx;
8683 chainlinks.spr(j)->y += dy;
8684 }
8685 }
8686 }
8687 }
8688 }
8689 else if(!switchhookclk)
8690 {
8691 reset_hookshot();
8692 }
8693 }
8694 else reset_hookshot();
8695 }
8696 else
8697 {
8698 sprite *t;
8699 int32_t i;
8700
8701
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 145 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 145 times.
145 for(i=0; i<Lwpns.Count() && (Lwpns.spr(i)->id!=wHSHandle); i++)
8702 {
8703 /* do nothing */
8704 }
8705
8706 145 t = Lwpns.spr(i);
8707
8708
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 145 times.
435 for(i=0; i<Lwpns.Count(); i++)
8709 {
8710 290 sprite *s = Lwpns.spr(i);
8711
8712
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 145 times.
290 if(s->id==wHookshot)
8713 {
8714
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 124 times.
145 if (abs((s->y) - y) >= 1)
8715 {
8716
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 10 times.
21 if((s->y)>y)
8717 {
8718 10 y+=4;
8719
8720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(Lwpns.idFirst(wHSHandle)!=-1)
8721 {
8722 10 t->y+=4;
8723 10 }
8724
8725 10 hs_starty+=4;
8726 10 }
8727
8728
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 11 times.
21 if((s->y)<y)
8729 {
8730 11 y-=4;
8731
8732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(Lwpns.idFirst(wHSHandle)!=-1)
8733 {
8734 11 t->y-=4;
8735 11 }
8736
8737 11 hs_starty-=4;
8738 11 }
8739 21 }
8740 else
8741 {
8742 124 y = (s->y);
8743 }
8744
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 21 times.
145 if (abs((s->x) - x) >= 1)
8745 {
8746
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 107 times.
124 if((s->x)>x)
8747 {
8748 107 x+=4;
8749
8750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(Lwpns.idFirst(wHSHandle)!=-1)
8751 {
8752 107 t->x+=4;
8753 107 }
8754
8755 107 hs_startx+=4;
8756 107 }
8757
8758
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 17 times.
124 if((s->x)<x)
8759 {
8760 17 x-=4;
8761
8762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(Lwpns.idFirst(wHSHandle)!=-1)
8763 {
8764 17 t->x-=4;
8765 17 }
8766
8767 17 hs_startx-=4;
8768 17 }
8769 124 }
8770 else
8771 {
8772 21 x = (s->x);
8773 }
8774 145 }
8775 290 }
8776 }
8777 145 }
8778 729 }
8779 else
8780 {
8781 33 Lwpns.del(Lwpns.idFirst(wHSHandle));
8782 33 reset_hookshot();
8783 }
8784
8785
1/2
✓ Branch 0 taken 762 times.
✗ Branch 1 not taken.
762 if(hs_fix)
8786 {
8787 if(dir==up)
8788 {
8789 y=int32_t(y+7)&0xF0;
8790 }
8791
8792 if(dir==down)
8793 {
8794 y=int32_t(y+7)&0xF0;
8795 }
8796
8797 if(dir==left)
8798 {
8799 x=int32_t(x+7)&0xF0;
8800 }
8801
8802 if(dir==right)
8803 {
8804 x=int32_t(x+7)&0xF0;
8805 }
8806
8807 hs_fix=false;
8808 }
8809
8810 762 }
8811
8812
2/2
✓ Branch 0 taken 85605 times.
✓ Branch 1 taken 3309626 times.
3395231 if(!get_bit(quest_rules,qr_NO_L_R_BUTTON_INVENTORY_SWAP))
8813 {
8814
2/2
✓ Branch 0 taken 1817 times.
✓ Branch 1 taken 3307809 times.
3309626 if(DrunkrLbtn())
8815 1817 selectNextBWpn(SEL_LEFT);
8816
2/2
✓ Branch 0 taken 3305823 times.
✓ Branch 1 taken 1986 times.
3307809 else if(DrunkrRbtn())
8817 1986 selectNextBWpn(SEL_RIGHT);
8818 3309626 }
8819
4/4
✓ Branch 0 taken 85605 times.
✓ Branch 1 taken 3309626 times.
✓ Branch 2 taken 85041 times.
✓ Branch 3 taken 564 times.
3395231 if (get_bit(quest_rules, qr_SELECTAWPN) && get_bit(quest_rules, qr_USE_EX1_EX2_INVENTORYSWAP))
8820 {
8821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 564 times.
564 if (rEx3btn())
8822 selectNextAWpn(SEL_LEFT);
8823
2/2
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 1 times.
564 else if (rEx4btn())
8824 1 selectNextAWpn(SEL_RIGHT);
8825 564 }
8826
8827
2/2
✓ Branch 0 taken 3395170 times.
✓ Branch 1 taken 61 times.
3395231 if(rPbtn())
8828 {
8829
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 58 times.
61 if( !FFCore.runOnMapScriptEngine() ) //OnMap script replaces the 'onViewMap()' call
8830 58 onViewMap();
8831 61 }
8832
2/2
✓ Branch 0 taken 1847143 times.
✓ Branch 1 taken 3395231 times.
5242374 for(int32_t i=0; i<Lwpns.Count(); i++)
8833 {
8834 1847143 weapon *w = ((weapon*)Lwpns.spr(i));
8835
8836
5/6
✓ Branch 0 taken 1840404 times.
✓ Branch 1 taken 6739 times.
✓ Branch 2 taken 1656776 times.
✓ Branch 3 taken 183628 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1656776 times.
1847143 if(w->id == wArrow || w->id == wBrang || w->id == wCByrna)
8837 190367 addsparkle(i);
8838 1847143 }
8839
8840
1/2
✓ Branch 0 taken 3395231 times.
✗ Branch 1 not taken.
3395231 if(Lwpns.idCount(wPhantom))
8841 {
8842 addsparkle2(pDINSFIREROCKET,pDINSFIREROCKETTRAIL);
8843 addsparkle2(pDINSFIREROCKETRETURN,pDINSFIREROCKETTRAILRETURN);
8844 addsparkle2(pNAYRUSLOVEROCKET1,pNAYRUSLOVEROCKETTRAIL1);
8845 addsparkle2(pNAYRUSLOVEROCKET2,pNAYRUSLOVEROCKETTRAIL2);
8846 addsparkle2(pNAYRUSLOVEROCKETRETURN1,pNAYRUSLOVEROCKETTRAILRETURN1);
8847 addsparkle2(pNAYRUSLOVEROCKETRETURN2,pNAYRUSLOVEROCKETTRAILRETURN2);
8848 }
8849
8850 // Pay magic cost for Byrna beams
8851
8852 //Byrna needs a secondary timer, for 254+, as do all items that reduce MP on a per-frae basis. Essentially, we will do % divisor == 0 for that. -Z
8853
1/2
✓ Branch 0 taken 3395231 times.
✗ Branch 1 not taken.
3395231 if(Lwpns.idCount(wCByrna))
8854 {
8855 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
8856 int32_t itemid = ew->parentitem;
8857
8858 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
8859 {
8860 for(int32_t i=0; i<Lwpns.Count(); i++)
8861 {
8862 weapon *w = ((weapon*)Lwpns.spr(i));
8863
8864 if(w->id==wCByrna)
8865 {
8866 w->dead=1;
8867 }
8868
8869 }
8870 //kill the sound effect for the orbits -Z 14FEB2019
8871 stop_sfx(itemsbuf[itemid].usesound);
8872 }
8873 else paymagiccost(itemid);
8874 }
8875
8876
3/4
✓ Branch 0 taken 3391963 times.
✓ Branch 1 taken 3268 times.
✓ Branch 2 taken 3391963 times.
✗ Branch 3 not taken.
3395231 if(z==0&&fakez==0)
8877 {
8878 3391963 switchblock_z = 0;
8879
1/2
✓ Branch 0 taken 3391963 times.
✗ Branch 1 not taken.
3391963 if(switchblock_offset)
8880 {
8881 switchblock_offset=false;
8882 yofs += 8;
8883 }
8884 3391963 }
8885
2/2
✓ Branch 0 taken 31654 times.
✓ Branch 1 taken 3363577 times.
3395231 if(!isSideViewHero())
8886 {
8887 3363577 int32_t tx = x.getInt()+8,
8888 3363577 ty = y.getInt()+8;//(bigHitbox?8:12);
8889
4/4
✓ Branch 0 taken 3363447 times.
✓ Branch 1 taken 130 times.
✓ Branch 2 taken 105 times.
✓ Branch 3 taken 3363342 times.
3363577 if(!(unsigned(ty)>175 || unsigned(tx) > 255))
8890 {
8891
2/2
✓ Branch 0 taken 3363342 times.
✓ Branch 1 taken 10090026 times.
13453368 for(int32_t q = 0; q < 3; ++q)
8892 {
8893
4/4
✓ Branch 0 taken 6726684 times.
✓ Branch 1 taken 3363342 times.
✓ Branch 2 taken 1078570 times.
✓ Branch 3 taken 5648114 times.
10090026 if(q && !tmpscr2[q-1].valid) continue;
8894 4441912 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[COMBOPOS(tx,ty)]];
8895
3/4
✓ Branch 0 taken 950 times.
✓ Branch 1 taken 4440962 times.
✓ Branch 2 taken 950 times.
✗ Branch 3 not taken.
4441912 if(cmb.type != cCSWITCHBLOCK || !(cmb.usrflags&cflag9)) continue;
8896 int32_t b = 1;
8897 if(tx&8) b <<= 2;
8898 if(ty&8) b <<= 1;
8899 b |= (b<<4); //check equivalent effect flag too
8900 if((cmb.walk&b)==b) //solid and effecting
8901 {
8902 if(z==0&&fakez==0)
8903 {
8904 if(cmb.usrflags&cflag10)
8905 {
8906 if(!switchblock_offset)
8907 {
8908 switchblock_offset=true;
8909 yofs -= 8;
8910 }
8911 }
8912 else
8913 {
8914 if(switchblock_offset)
8915 {
8916 switchblock_offset=false;
8917 yofs += 8;
8918 }
8919 }
8920 }
8921 if(cmb.attributes[2]>0 && switchblock_z>=0)
8922 {
8923 if(z==0&&fakez==0)
8924 switchblock_z = zc_max(switchblock_z,zslongToFix(cmb.attributes[2]));
8925 else if(SWITCHBLOCK_STATE < zslongToFix(cmb.attributes[2]))
8926 {
8927 switchblock_z += zslongToFix(cmb.attributes[2])-SWITCHBLOCK_STATE;
8928 }
8929 }
8930 else switchblock_z = -1;
8931 break;
8932 }
8933 }
8934 3363342 }
8935 3363577 }
8936 3395231 ClearhitHeroUIDs(); //clear them before we advance.
8937 3395231 checkhit();
8938
8939 3395231 bool forcedeath = dying_flags&DYING_FORCED;
8940 3395231 bool norev = (dying_flags&DYING_NOREV);
8941
4/6
✓ Branch 0 taken 3395231 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 3395193 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
3395231 if(forcedeath || (game->get_life()<=0 && !immortal))
8942 {
8943
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(forcedeath)
8944 game->set_life(0);
8945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(!norev)
8946
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 9728 times.
9766 for(size_t slot = 0; slot < 256; ++slot)
8947 {
8948
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(size_t bind = game->get_bottle_slot(slot))
8949 {
8950 bottletype const* bt = &QMisc.bottle_types[bind-1];
8951 if(!(bt->flags&BTFLAG_AUTOONDEATH))
8952 continue;
8953 word toFill[3] = { 0 };
8954 for(size_t q = 0; q < 3; ++q)
8955 {
8956 char c = bt->counter[q];
8957 if(c > -1)
8958 {
8959 if(bt->flags & (1<<q))
8960 {
8961 toFill[q] = (bt->amount[q]==100)
8962 ? game->get_maxcounter(c)
8963 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
8964 }
8965 else toFill[q] = bt->amount[q];
8966 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
8967 {
8968 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
8969 }
8970 }
8971 }
8972 if(bt->flags & BTFLAG_CURESWJINX)
8973 {
8974 swordclk = 0;
8975 verifyAWpn();
8976 }
8977 if(bt->flags & BTFLAG_CUREITJINX)
8978 itemclk = 0;
8979 if(word max = std::max(toFill[0], std::max(toFill[1], toFill[2])))
8980 {
8981 int32_t itemid = find_bottle_for_slot(slot,true);
8982 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
8983 if(itemid > -1)
8984 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
8985 for(size_t q = 0; q < 20; ++q)
8986 do_death_refill_waitframe();
8987 double inc = max/60.0; //1 second
8988 double xtra[3]{ 0 };
8989 for(size_t q = 0; q < 60; ++q)
8990 {
8991 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
8992 sfx(QMisc.miscsfx[sfxREFILL]);
8993 for(size_t j = 0; j < 3; ++j)
8994 {
8995 xtra[j] += inc;
8996 word f = floor(xtra[j]);
8997 xtra[j] -= f;
8998 if(toFill[j] > f)
8999 {
9000 toFill[j] -= f;
9001 game->change_counter(f,bt->counter[j]);
9002 }
9003 else if(toFill[j])
9004 {
9005 game->change_counter(toFill[j],bt->counter[j]);
9006 toFill[j] = 0;
9007 }
9008 }
9009 do_death_refill_waitframe();
9010 }
9011 for(size_t j = 0; j < 3; ++j)
9012 {
9013 if(toFill[j])
9014 {
9015 game->change_counter(toFill[j],bt->counter[j]);
9016 toFill[j] = 0;
9017 }
9018 }
9019 for(size_t q = 0; q < 20; ++q)
9020 do_death_refill_waitframe();
9021 }
9022 game->set_bottle_slot(slot,bt->next_type);
9023 if(game->get_life() > 0)
9024 {
9025 dying_flags = 0;
9026 forcedeath = false;
9027 break; //Revived! Stop drinking things...
9028 }
9029 }
9030 9766 }
9031
9032
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 26 times.
38 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
9033 {
9034
3/6
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
12 if(forcedeath || (game->get_life()<=0 && !immortal)) //Not saved by fairy
9035 {
9036 // So scripts can have one frame to handle hp zero events
9037
3/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 11 times.
12 if(norev || false == (last_hurrah = !last_hurrah))
9038 {
9039 1 dying_flags = 0;
9040 1 drunkclk=0;
9041 1 lstunclock = 0;
9042 1 is_conveyor_stunned = 0;
9043 1 FFCore.setHeroAction(dying);
9044 1 FFCore.deallocateAllArrays(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME);
9045 1 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE);
9046 1 ALLOFF(true,true);
9047 1 GameFlags |= GAMEFLAG_NO_F6;
9048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!debug_enabled)
9049 {
9050 1 Paused=false;
9051 1 }
9052
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!get_bit(quest_rules,qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9053 {
9054 FFCore.runOnDeathEngine();
9055 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH);
9056 }
9057 1 Playing = false;
9058 1 heroDeathAnimation();
9059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(get_bit(quest_rules,qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9060 {
9061 1 Playing = true;
9062 1 FFCore.runOnDeathEngine();
9063 1 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH);
9064 1 Playing = false;
9065 1 }
9066 1 GameFlags &= ~GAMEFLAG_NO_F6;
9067 1 ALLOFF(true,true);
9068 1 return true;
9069 }
9070 11 }
9071 11 }
9072 else //2.50.x
9073 {
9074 // So scripts can have one frame to handle hp zero events
9075
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 13 times.
26 if(false == (last_hurrah = !last_hurrah))
9076 {
9077 13 drunkclk=0;
9078 13 heroDeathAnimation();
9079
9080 13 return true;
9081 }
9082 }
9083 24 }
9084 3395193 else last_hurrah=false;
9085
9086
2/2
✓ Branch 0 taken 19385 times.
✓ Branch 1 taken 3375832 times.
3395217 if(swordclk>0)
9087 {
9088 19385 --swordclk;
9089
2/2
✓ Branch 0 taken 19288 times.
✓ Branch 1 taken 97 times.
19385 if(!swordclk) verifyAWpn();
9090 19385 }
9091
2/2
✓ Branch 0 taken 3344 times.
✓ Branch 1 taken 3391873 times.
3395217 if(itemclk>0)
9092 3344 --itemclk;
9093
9094
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 3394925 times.
3395217 if(inwallm)
9095 {
9096 292 attackclk=0;
9097 292 herostep();
9098
9099
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 3 times.
292 if(CarryHero()==false)
9100 3 restart_level();
9101
9102 292 solid_update(false);
9103 292 return false;
9104 }
9105
9106
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3394924 times.
3394925 if(ewind_restart)
9107 {
9108 1 attackclk=0;
9109 1 restart_level();
9110 1 xofs=0;
9111 1 action=none; FFCore.setHeroAction(none);
9112 1 ewind_restart=false;
9113 1 solid_update(false);
9114 1 return false;
9115 }
9116
9117
2/2
✓ Branch 0 taken 3392469 times.
✓ Branch 1 taken 2455 times.
3394924 if(hopclk)
9118 {
9119 2455 action=hopping; FFCore.setHeroAction(hopping);
9120 2455 }
9121
2/2
✓ Branch 0 taken 3394714 times.
✓ Branch 1 taken 210 times.
3394924 if(fallclk)
9122 {
9123 210 action=falling; FFCore.setHeroAction(falling);
9124 210 }
9125
9126 3394924 handle_passive_buttons();
9127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3394924 times.
3394924 if(liftclk)
9128 {
9129 if(lift_wpn)
9130 {
9131 action=lifting; FFCore.setHeroAction(lifting);
9132 }
9133 else
9134 {
9135 liftclk = 0;
9136 tliftclk = 0;
9137 }
9138 }
9139
1/2
✓ Branch 0 taken 3394924 times.
✗ Branch 1 not taken.
3394924 else if(lift_wpn)
9140 {
9141 handle_lift(false);
9142 }
9143
9144
9145 // get user input or do other animation
9146 3394924 freeze_guys=false; // reset this flag, set it again if holding
9147
9148
14/16
✓ Branch 0 taken 3369796 times.
✓ Branch 1 taken 25128 times.
✓ Branch 2 taken 3361602 times.
✓ Branch 3 taken 8194 times.
✓ Branch 4 taken 3361212 times.
✓ Branch 5 taken 390 times.
✓ Branch 6 taken 3361082 times.
✓ Branch 7 taken 130 times.
✓ Branch 8 taken 3361082 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3361082 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3349531 times.
✓ Branch 13 taken 11551 times.
✓ Branch 14 taken 21 times.
✓ Branch 15 taken 3349510 times.
3394924 if(action != landhold1 && action != landhold2 && action != waterhold1 && action != waterhold2 && action != sidewaterhold1 && action != sidewaterhold2 && fairyclk==0 && holdclk>0)
9149 {
9150 21 holdclk=0;
9151 21 }
9152
9153 3394924 active_shield_id = refreshActiveShield();
9154 3394924 bool sh = active_shield_id > -1;
9155 3394924 itemdata const& shield = itemsbuf[active_shield_id];
9156 //Handle direction forcing. This runs every frame so that scripts can interact with dir still.
9157 3394924 shield_forcedir = -1;
9158
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3394924 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3394924 if(sh && action != rafting && (shield.flags & ITEM_FLAG11)) //Lock Dir
9159 {
9160 shield_forcedir = dir;
9161 }
9162
1/2
✓ Branch 0 taken 3394924 times.
✗ Branch 1 not taken.
3394924 if(sh != shield_active) //Toggle active shield on/off
9163 {
9164 shield_active = sh;
9165 if(sh) //Toggle active shield on
9166 {
9167 sfx(shield.usesound2); //'Activate' sfx
9168 }
9169 }
9170
9171 3394924 bool isthissolid = false;
9172
10/12
✓ Branch 0 taken 21228 times.
✓ Branch 1 taken 520 times.
✓ Branch 2 taken 704 times.
✓ Branch 3 taken 48085 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 33322 times.
✓ Branch 6 taken 3254072 times.
✓ Branch 7 taken 31357 times.
✓ Branch 8 taken 210 times.
✓ Branch 9 taken 2455 times.
✓ Branch 10 taken 2971 times.
✗ Branch 11 not taken.
3394924 switch(action)
9173 {
9174 case gothit:
9175
2/2
✓ Branch 0 taken 1001 times.
✓ Branch 1 taken 30356 times.
31357 if(attackclk)
9176
2/2
✓ Branch 0 taken 879 times.
✓ Branch 1 taken 122 times.
1123 if(!doattack())
9177 {
9178 122 attackclk=spins=0;
9179 122 tapping=false;
9180 122 }
9181
9182 31357 break;
9183
9184 case drowning:
9185 case lavadrowning:
9186 case sidedrowning:
9187 {
9188 704 herostep(); // maybe this line should be elsewhere?
9189
9190 //!DROWN
9191 // Helpful comment to find drowning -Dimi
9192
9193 704 drop_liftwpn();
9194
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 11 times.
704 if(--drownclk==0)
9195 {
9196 11 action=none; FFCore.setHeroAction(none);
9197 11 int32_t water = iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
9198 11 int32_t damage = combobuf[water].attributes[0]/10000L;
9199 //if (damage == 0 && !(combobuf[water].usrflags&cflag7)) damage = (game->get_hp_per_heart()/4);
9200 11 drownCombo = 0;
9201
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (combobuf[water].type != cWATER) damage = 4;
9202 11 game->set_life(vbound(game->get_life()-damage,0, game->get_maxlife()));
9203 11 go_respawn_point();
9204 11 hclk=48;
9205 11 }
9206
9207 704 break;
9208 }
9209 case falling:
9210 {
9211 210 herostep();
9212 210 pitfall();
9213 210 break;
9214 }
9215 case freeze:
9216 case sideswimfreeze:
9217 case scrolling:
9218 48085 break;
9219
9220 case casting:
9221 case sideswimcasting:
9222 {
9223 if(magicitem==-1)
9224 {
9225 action=none; FFCore.setHeroAction(none);
9226 }
9227
9228 break;
9229 }
9230 case landhold1:
9231 case landhold2:
9232 {
9233
2/2
✓ Branch 0 taken 241 times.
✓ Branch 1 taken 33081 times.
33322 if(--holdclk <= 0)
9234 {
9235 //restart music
9236
4/4
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 178 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 28 times.
241 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9237 28 playLevelMusic();
9238
9239 241 action=none; FFCore.setHeroAction(none);
9240 241 }
9241 else
9242 33081 freeze_guys=true;
9243
9244 33322 break;
9245 }
9246 case waterhold1:
9247 case waterhold2:
9248 case sidewaterhold1:
9249 case sidewaterhold2:
9250 {
9251 520 diveclk=0;
9252
9253
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 516 times.
520 if(--holdclk <= 0)
9254 {
9255 //restart music
9256
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9257 playLevelMusic();
9258
9259 4 SetSwim();
9260 4 }
9261 else
9262 516 freeze_guys=true;
9263
9264 520 break;
9265 }
9266 case hopping:
9267 {
9268
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2455 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2455 if(DRIEDLAKE)
9269 {
9270 action=none; FFCore.setHeroAction(none);
9271 hopclk = 0;
9272 diveclk = 0;
9273 break;
9274 }
9275
9276 2455 do_hopping();
9277 2455 break;
9278 }
9279 case inwind:
9280 {
9281 2971 int32_t i=Lwpns.idFirst(wWind);
9282
9283
2/2
✓ Branch 0 taken 2930 times.
✓ Branch 1 taken 41 times.
2971 if(i<0)
9284 {
9285 41 bool exit=false;
9286
9287
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 21 times.
41 if(whirlwind==255)
9288 {
9289 20 exit=true;
9290 20 }
9291
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
21 else if(y<=0 && dir==up) y=-1;
9292
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
21 else if(y>=160 && dir==down) y=161;
9293
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
21 else if(x<=0 && dir==left) x=-1;
9294
2/4
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
21 else if(x>=240 && dir==right) x=241;
9295 else exit=true;
9296
9297
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 20 times.
41 if(exit)
9298 {
9299 20 action=none; FFCore.setHeroAction(none);
9300 20 xofs=0;
9301 20 whirlwind=0;
9302 20 lstep=0;
9303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if ( dontdraw < 2 ) dontdraw=0;
9304 20 set_respawn_point();
9305 20 }
9306 41 }
9307 /*
9308 else if (((weapon*)Lwpns.spr(i))->dead==1)
9309 {
9310 whirlwind=255;
9311 }
9312 */
9313 else
9314 {
9315 2930 x=Lwpns.spr(i)->x;
9316 2930 y=Lwpns.spr(i)->y;
9317 2930 dir=Lwpns.spr(i)->dir;
9318 }
9319 }
9320 2971 break;
9321 case lifting:
9322 handle_lift();
9323 break;
9324
9325 case sideswimming:
9326 case sideswimattacking:
9327 case sideswimhit:
9328 case swimhit:
9329 case swimming:
9330 {
9331
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
21228 if(DRIEDLAKE)
9332 {
9333 action=none; FFCore.setHeroAction(none);
9334 hopclk=0;
9335 break;
9336 }
9337
9338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21228 times.
21228 bool shouldbreak = (action == sideswimhit || action == swimhit); //!DIMITODO: "Can walk while hurt" compat needs to be added here.
9339
9340
4/4
✓ Branch 0 taken 10599 times.
✓ Branch 1 taken 10629 times.
✓ Branch 2 taken 89 times.
✓ Branch 3 taken 10510 times.
21228 if((frame&1) && !shouldbreak)
9341 10510 herostep();
9342
9343
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21228 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21228 times.
✓ Branch 4 taken 1712 times.
✓ Branch 5 taken 19516 times.
22940 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
9344
4/6
✓ Branch 0 taken 19516 times.
✓ Branch 1 taken 1712 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1712 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1712 times.
21228 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
9345
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1712 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1712 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1712 times.
1712 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
9346
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1712 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1712 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1712 times.
21228 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
9347
4/4
✓ Branch 0 taken 19961 times.
✓ Branch 1 taken 1267 times.
✓ Branch 2 taken 19961 times.
✓ Branch 3 taken 1267 times.
21228 if ((get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) //Since hopping won't be set with this on, something needs to kick Hero out of water...
9348 {
9349
4/4
✓ Branch 0 taken 1264 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1255 times.
✓ Branch 3 taken 1 times.
2523 if(!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+9), currmap, currscr, -1, x.getInt()+4,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+15), currmap, currscr, -1, x.getInt()+4,y.getInt()+15, true, false)
9350
4/4
✓ Branch 0 taken 1262 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1256 times.
✓ Branch 3 taken 6 times.
1264 || !iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+9), currmap, currscr, -1, x.getInt()+11,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+15), currmap, currscr, -1, x.getInt()+11,y.getInt()+15, true, false))
9351 {
9352 12 hopclk=0;
9353 12 diveclk=0;
9354
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if (action != sideswimattacking && action != attacking) {action=none; FFCore.setHeroAction(none);}
9355 else {action=attacking; FFCore.setHeroAction(attacking);}
9356 12 hopdir=-1;
9357 12 }
9358 1267 }
9359
2/2
✓ Branch 0 taken 187 times.
✓ Branch 1 taken 21041 times.
21228 if (shouldbreak) break;
9360
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 21029 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
21041 if (action == swimming || action == sideswimming || action == sideswimattacking)
9361 {
9362 21029 int32_t watercheck = iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
9363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21029 times.
21029 if (combobuf[watercheck].usrflags&cflag2)
9364 {
9365 if (current_item(combobuf[watercheck].attribytes[2]) < combobuf[watercheck].attribytes[3])
9366 {
9367 onpassivedmg = true;
9368 if (damageovertimeclk == 0)
9369 {
9370 int32_t curhp = game->get_life();
9371 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
9372 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
9373 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
9374 if (game->get_life() < curhp && combobuf[watercheck].usrflags&cflag7)
9375 {
9376 hclk = 48;
9377 hitdir = -1;
9378 if (IsSideSwim()) {action = sideswimhit; FFCore.setHeroAction(sideswimhit);}
9379 else {action = swimhit; FFCore.setHeroAction(swimhit);}
9380 }
9381 }
9382 if (combobuf[watercheck].attribytes[1] > 0)
9383 {
9384 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
9385 else --damageovertimeclk;
9386 }
9387 else damageovertimeclk = 0;
9388 }
9389 else damageovertimeclk = 0;
9390 }
9391 21029 else damageovertimeclk = 0;
9392 //combobuf[watercheck].attributes[0]
9393 21029 }
9394
9395 21041 }
9396 [[fallthrough]];
9397 default:
9398 3275113 movehero(); // call the main movement routine
9399 3275113 }
9400
9401
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3394924 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3394924 if(shield_forcedir > -1 && action != rafting)
9402 dir = shield_forcedir;
9403
9404
2/2
✓ Branch 0 taken 3380404 times.
✓ Branch 1 taken 14520 times.
3394924 if(!get_bit(quest_rules,qr_OLD_RESPAWN_POINTS))
9405 14520 set_respawn_point(false); //Keep the 'last safe location' updated!
9406
9407 // check for ladder removal
9408
2/2
✓ Branch 0 taken 271827 times.
✓ Branch 1 taken 3123097 times.
3394924 if(diagonalMovement)
9409 {
9410
2/2
✓ Branch 0 taken 271804 times.
✓ Branch 1 taken 23 times.
271827 if(ladderx+laddery)
9411 {
9412
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(ladderdir==up)
9413 {
9414 if((laddery-y.getInt()>=(16+(ladderstart==dir?ladderstart==down?1:0:0))) || (laddery-y.getInt()<=(-16-(ladderstart==dir?ladderstart==up?1:0:0))) || (abs(ladderx-x.getInt())>8))
9415 {
9416 reset_ladder();
9417 }
9418 }
9419 else
9420 {
9421
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 22 times.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 22 times.
23 if((abs(laddery-y.getInt())>8) || (ladderx-x.getInt()>=(16+(ladderstart==dir?ladderstart==right?1:0:0))) || (ladderx-x.getInt()<=(-16-(ladderstart==dir?ladderstart==left?1:0:0))))
9422 {
9423 1 reset_ladder();
9424 1 }
9425 }
9426 23 }
9427 271827 }
9428 else
9429 {
9430
4/4
✓ Branch 0 taken 102004 times.
✓ Branch 1 taken 3021093 times.
✓ Branch 2 taken 47043 times.
✓ Branch 3 taken 54961 times.
3123097 if((abs(laddery-y.getInt())>=16) || (abs(ladderx-x.getInt())>=16))
9431 {
9432 3068136 reset_ladder();
9433 3068136 }
9434 }
9435
9436
2/2
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 3394565 times.
3394924 if(ilswim)
9437 359 landswim++;
9438 3394565 else landswim=0;
9439
9440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3394924 times.
3394924 if(hopclk!=0xFF) ilswim=false;
9441
9442
3/4
✓ Branch 0 taken 6225 times.
✓ Branch 1 taken 3388699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6225 times.
3394924 if((!loaded_guys) && (frame - newscr_clk >= 1))
9443 {
9444
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 6220 times.
6225 if(tmpscr->room==rGANON)
9445 {
9446 5 ganon_intro();
9447 5 }
9448 else
9449 {
9450 6220 loadguys();
9451 }
9452 6225 }
9453
9454
2/2
✓ Branch 0 taken 6512 times.
✓ Branch 1 taken 3388412 times.
3394924 if(frame - newscr_clk >= 2)
9455 {
9456 3388412 loadenemies();
9457 3388412 }
9458
9459 // check lots of other things
9460 3394924 checkscroll();
9461
9462
6/8
✓ Branch 0 taken 3391974 times.
✓ Branch 1 taken 2950 times.
✓ Branch 2 taken 3391281 times.
✓ Branch 3 taken 693 times.
✓ Branch 4 taken 3391281 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3391281 times.
3394924 if(action!=inwind && action!=drowning && action != sidedrowning && action!=lavadrowning)
9463 {
9464 3391281 checkspecial();
9465 3391281 checkitems();
9466 3391281 checklocked(); //This has issues if Hero's action is WALKING, in 8-way moveent.
9467
2/2
✓ Branch 0 taken 14958 times.
✓ Branch 1 taken 3376323 times.
3391281 if(get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
9468 {
9469 3376323 oldchecklockblock();
9470 3376323 oldcheckbosslockblock();
9471 3376323 }
9472
2/2
✓ Branch 0 taken 144625 times.
✓ Branch 1 taken 3246656 times.
3391281 if(get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
9473 {
9474 3246656 oldcheckchest(cCHEST);
9475 3246656 oldcheckchest(cLOCKEDCHEST);
9476 3246656 oldcheckchest(cBOSSCHEST);
9477 3246656 }
9478 3391281 checkpushblock();
9479 3391281 checkswordtap();
9480
9481
2/2
✓ Branch 0 taken 762 times.
✓ Branch 1 taken 3390519 times.
3391281 if(hookshot_frozen==false)
9482 {
9483 3390519 checkspecial2(&lsave);
9484 3390519 }
9485
9486
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3391277 times.
3391281 if(action==won)
9487 {
9488 4 return true;
9489 }
9490 3391277 }
9491
9492 // Somehow Hero was displaced from the fairy flag...
9493
3/6
✓ Branch 0 taken 11551 times.
✓ Branch 1 taken 3383369 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11551 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3394920 if(fairyclk && action != freeze && action != sideswimfreeze)
9494 {
9495 fairyclk = holdclk = refill_why = 0;
9496 }
9497
9498
3/4
✓ Branch 0 taken 3394920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3393236 times.
✓ Branch 3 taken 1684 times.
3394920 if((!activated_timed_warp) && (tmpscr->timedwarptics>0))
9499 {
9500 1684 tmpscr->timedwarptics--;
9501
9502
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 7 times.
1684 if(tmpscr->timedwarptics==0)
9503 {
9504 7 activated_timed_warp=true;
9505
9506
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 if(tmpscr->flags4 & fTIMEDDIRECT)
9507 {
9508 3 didpit=true;
9509 3 pitx=x;
9510 3 pity=y;
9511 3 }
9512
9513 7 int32_t index2 = 0;
9514
9515
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tmpscr->flags5 & fRANDOMTIMEDWARP) index2=zc_oldrand()%4;
9516
9517 7 sdir = dir;
9518 7 dowarp(1,index2);
9519 7 }
9520 1684 }
9521
9522 3394920 bool awarp = false;
9523 //!DIMI: Global Combo Effects (AUTO STUFF)
9524
2/2
✓ Branch 0 taken 128047 times.
✓ Branch 1 taken 3394920 times.
3522967 for(auto& p : slopes)
9525 {
9526 128047 slope_object& s = p.second;
9527 128047 s.updateslope(); //sets old x/y poses
9528 }
9529
2/2
✓ Branch 0 taken 3394919 times.
✓ Branch 1 taken 597505894 times.
600900813 for(int32_t i=0; i<176; ++i)
9530 {
9531
2/2
✓ Branch 0 taken 2403456 times.
✓ Branch 1 taken 2397233941 times.
2399637397 for(int32_t layer=0; layer<7; ++layer)
9532 {
9533
2/2
✓ Branch 0 taken 1799728047 times.
✓ Branch 1 taken 597505894 times.
2397233941 int32_t cid = ( layer ) ? MAPCOMBOL(layer,COMBOX(i),COMBOY(i)) : MAPCOMBO(COMBOX(i),COMBOY(i));
9534 2397233941 newcombo const& cmb = combobuf[cid];
9535
9536
2/2
✓ Branch 0 taken 16824192 times.
✓ Branch 1 taken 2380409749 times.
2397233941 if(!get_bit(quest_rules,qr_AUTOCOMBO_ANY_LAYER))
9537 {
9538
2/2
✓ Branch 0 taken 595102437 times.
✓ Branch 1 taken 1785307312 times.
2380409749 if(layer > 2) break;
9539
4/4
✓ Branch 0 taken 595102437 times.
✓ Branch 1 taken 1190204875 times.
✓ Branch 2 taken 571941013 times.
✓ Branch 3 taken 23161424 times.
1785307312 if (layer == 1 && !get_bit(quest_rules,qr_AUTOCOMBO_LAYER_1)) continue;
9540
4/4
✓ Branch 0 taken 595102437 times.
✓ Branch 1 taken 618263862 times.
✓ Branch 2 taken 23161424 times.
✓ Branch 3 taken 571941013 times.
1213366299 if (layer == 2 && !get_bit(quest_rules,qr_AUTOCOMBO_LAYER_2)) continue;
9541 641425286 }
9542 658249478 int32_t ind=0;
9543
9544 //AUTOMATIC TRIGGER CODE
9545
1/2
✓ Branch 0 taken 658249478 times.
✗ Branch 1 not taken.
658249478 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
9546 {
9547 do_trigger_combo(layer, i);
9548 }
9549
9550 //AUTO WARP CODE
9551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 658249478 times.
658249478 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
9552 {
9553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 658249478 times.
658249478 if(cmb.type==cAWARPA)
9554 {
9555 awarp=true;
9556 ind=0;
9557 }
9558
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 658249477 times.
658249478 else if(cmb.type==cAWARPB)
9559 {
9560 1 awarp=true;
9561 1 ind=1;
9562 1 }
9563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 658249477 times.
658249477 else if(cmb.type==cAWARPC)
9564 {
9565 awarp=true;
9566 ind=2;
9567 }
9568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 658249477 times.
658249477 else if(cmb.type==cAWARPD)
9569 {
9570 awarp=true;
9571 ind=3;
9572 }
9573
1/2
✓ Branch 0 taken 658249477 times.
✗ Branch 1 not taken.
658249477 else if(cmb.type==cAWARPR)
9574 {
9575 awarp=true;
9576 ind=zc_oldrand()%4;
9577 }
9578 658249478 }
9579
2/2
✓ Branch 0 taken 658249477 times.
✓ Branch 1 taken 1 times.
658249478 if(awarp)
9580 {
9581
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(tmpscr->flags5&fDIRECTAWARP)
9582 {
9583 didpit=true;
9584 pitx=x;
9585 pity=y;
9586 }
9587
9588 1 sdir = dir;
9589 1 dowarp(1,ind);
9590 1 break;
9591 }
9592 658249477 }
9593
2/2
✓ Branch 0 taken 597505893 times.
✓ Branch 1 taken 1 times.
597505894 if(awarp) break;
9594 597505893 }
9595
9596 3394920 awarp=false;
9597
9598 3394920 word c = tmpscr->numFFC();
9599
2/2
✓ Branch 0 taken 3394914 times.
✓ Branch 1 taken 104822742 times.
108217656 for(word i=0; i<c; i++)
9600 {
9601 104822742 int32_t ind=0;
9602
9603 104822742 newcombo const& cmb = combobuf[tmpscr->ffcs[i].getData()];
9604
9605
1/2
✓ Branch 0 taken 104822742 times.
✗ Branch 1 not taken.
104822742 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
9606 {
9607 do_trigger_combo_ffc(i);
9608 }
9609
9610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104822742 times.
104822742 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
9611 {
9612
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 104822739 times.
104822742 if(cmb.type==cAWARPA)
9613 {
9614 3 awarp=true;
9615 3 ind=0;
9616 3 }
9617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104822739 times.
104822739 else if(cmb.type==cAWARPB)
9618 {
9619 awarp=true;
9620 ind=1;
9621 }
9622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104822739 times.
104822739 else if(cmb.type==cAWARPC)
9623 {
9624 awarp=true;
9625 ind=2;
9626 }
9627
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 104822736 times.
104822739 else if(cmb.type==cAWARPD)
9628 {
9629 3 awarp=true;
9630 3 ind=3;
9631 3 }
9632
1/2
✓ Branch 0 taken 104822736 times.
✗ Branch 1 not taken.
104822736 else if(cmb.type==cAWARPR)
9633 {
9634 awarp=true;
9635 ind=zc_oldrand()%4;
9636 }
9637 104822742 }
9638
9639
2/2
✓ Branch 0 taken 104822736 times.
✓ Branch 1 taken 6 times.
104822742 if(awarp)
9640 {
9641
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(tmpscr->flags5&fDIRECTAWARP)
9642 {
9643 didpit=true;
9644 pitx=x;
9645 pity=y;
9646 }
9647
9648 6 sdir = dir;
9649 6 dowarp(1,ind);
9650 6 break;
9651 }
9652 104822736 }
9653 3394920 zfix dx, dy;
9654
7/8
✓ Branch 0 taken 31656 times.
✓ Branch 1 taken 3363264 times.
✓ Branch 2 taken 16618 times.
✓ Branch 3 taken 15038 times.
✓ Branch 4 taken 2082 times.
✓ Branch 5 taken 14536 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2082 times.
3394920 if (sideview_mode() && !on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && on_sideview_solid_oldpos(x, y,old_x,old_y, false, 2) && !toogam)
9655 {
9656
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 2045 times.
2082 if (slide_slope(this, dx, dy, slopeid))
9657 {
9658 2045 onplatid = 5;
9659
3/4
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 1265 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 780 times.
2045 if (dx || dy) push_move(dx, dy);
9660 2045 }
9661 2082 }
9662
2/2
✓ Branch 0 taken 3392273 times.
✓ Branch 1 taken 2647 times.
3394920 if (onplatid <= 0) slopeid = 0;
9663 2647 else --onplatid;
9664
2/2
✓ Branch 0 taken 2697357 times.
✓ Branch 1 taken 697563 times.
3394920 bool onplatform = (on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && !Up());
9665
5/6
✓ Branch 0 taken 984 times.
✓ Branch 1 taken 3394904 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 984 times.
✓ Branch 4 taken 968 times.
✓ Branch 5 taken 3394920 times.
3395888 for (auto q = 0; (check_slope(this, true) && !toogam) && q < 2; ++q)
9666 {
9667
2/4
✓ Branch 0 taken 968 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 968 times.
968 if (check_slope(this, true) && !toogam)
9668 {
9669 968 slope_info const& s = get_slope(this, true).get_info();
9670 968 bool staircheck = false;
9671
4/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 848 times.
✓ Branch 2 taken 57 times.
✓ Branch 3 taken 63 times.
968 if (s.slope() != slopeid && slopeid) staircheck = true;
9672
2/2
✓ Branch 0 taken 931 times.
✓ Branch 1 taken 37 times.
968 if (onplatform) staircheck = true;
9673 968 slope_push_int(s, this, dx, dy, staircheck, platformfell2);
9674
9675
4/4
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 734 times.
✓ Branch 2 taken 206 times.
✓ Branch 3 taken 28 times.
968 if (dx || dy)
9676 {
9677 940 int32_t pushret = push_move(dx,dy);
9678
2/2
✓ Branch 0 taken 920 times.
✓ Branch 1 taken 20 times.
940 onplatform = (on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && !Up());
9679
4/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 830 times.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 59 times.
940 if (s.slope() != slopeid && slopeid) staircheck = true;
9680
2/2
✓ Branch 0 taken 922 times.
✓ Branch 1 taken 18 times.
940 if (onplatform) staircheck = true;
9681
4/4
✓ Branch 0 taken 908 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 882 times.
940 if(sideview_mode() && slopeid)
9682 882 onplatid = 5;
9683
1/2
✓ Branch 0 taken 940 times.
✗ Branch 1 not taken.
940 if (pushret == 1)
9684 {
9685 dx = -1;
9686 dy = 0;
9687 slope_push_int(s, this, dx, dy, staircheck);
9688 push_move(dx,dy);
9689 }
9690
2/2
✓ Branch 0 taken 928 times.
✓ Branch 1 taken 12 times.
940 if (pushret == 2)
9691 {
9692 12 dx = 0;
9693 12 dy = -1;
9694 12 slope_push_int(s, this, dx, dy, staircheck);
9695 12 push_move(dx,dy);
9696 12 }
9697 940 }
9698 968 }
9699 968 }
9700
9701
2/2
✓ Branch 0 taken 3394900 times.
✓ Branch 1 taken 20 times.
3394920 if(ffwarp)
9702 {
9703
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1 times.
20 if(ffpit)
9704 {
9705 1 ffpit=false;
9706 1 didpit=true;
9707 1 pitx=x;
9708 1 pity=y;
9709 1 }
9710
9711 20 ffwarp=false;
9712 20 dowarp(1,0);
9713 20 }
9714
9715 //Hero->WarpEx
9716
2/2
✓ Branch 0 taken 3394904 times.
✓ Branch 1 taken 16 times.
3394920 if ( FFCore.warpex[wexActive] )
9717 {
9718 if(DEVLOGGING) zprint("Running warpex from hero.cpp\n");
9719 16 FFCore.warpex[wexActive] = 0;
9720 16 int32_t temp_warpex[wexActive] = {0}; //to hold the values as we clear the FFCore array. -Z
9721
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 16 times.
160 for ( int32_t q = 0; q < wexActive; q++ )
9722 {
9723 144 temp_warpex[q] = FFCore.warpex[q];
9724 144 FFCore.warpex[q] = 0;
9725 144 }
9726 32 FFCore.warp_player( temp_warpex[wexType], temp_warpex[wexDMap], temp_warpex[wexScreen], temp_warpex[wexX],
9727 16 temp_warpex[wexY], temp_warpex[wexEffect], temp_warpex[wexSound], temp_warpex[wexFlags], temp_warpex[wexDir]);
9728 16 }
9729
9730 // walk through bombed doors and fake walls
9731 3394920 bool walk=false;
9732 3394920 int32_t dtype=dBOMBED;
9733
9734
2/2
✓ Branch 0 taken 3362373 times.
✓ Branch 1 taken 32547 times.
3394920 if(pushing>=24) dtype=dWALK;
9735
9736
15/18
✓ Branch 0 taken 2307850 times.
✓ Branch 1 taken 1087070 times.
✓ Branch 2 taken 2287209 times.
✓ Branch 3 taken 20641 times.
✓ Branch 4 taken 2287209 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2284141 times.
✓ Branch 7 taken 3068 times.
✓ Branch 8 taken 2282029 times.
✓ Branch 9 taken 2112 times.
✓ Branch 10 taken 2282000 times.
✓ Branch 11 taken 29 times.
✓ Branch 12 taken 2273472 times.
✓ Branch 13 taken 8528 times.
✓ Branch 14 taken 2273472 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 2273472 times.
3394920 if(isdungeon() && action!=freeze && action != sideswimfreeze && loaded_guys && !inlikelike && !diveclk && action!=rafting && !lstunclock && !is_conveyor_stunned)
9737 {
9738
12/16
✓ Branch 0 taken 23202 times.
✓ Branch 1 taken 2250270 times.
✓ Branch 2 taken 368715 times.
✓ Branch 3 taken 1881555 times.
✓ Branch 4 taken 368715 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 368715 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 73437 times.
✓ Branch 11 taken 295278 times.
✓ Branch 12 taken 20574 times.
✓ Branch 13 taken 52863 times.
✓ Branch 14 taken 20504 times.
✓ Branch 15 taken 70 times.
2273472 if(((dtype==dBOMBED)?DrunkUp():dir==up) && ((diagonalMovement||NO_GRIDLOCK)?x>112&&x<128:x==120) && y<=32 && tmpscr->door[0]==dtype)
9739 {
9740 70 walk=true;
9741 70 dir=up;
9742 70 }
9743
9744
12/16
✓ Branch 0 taken 23202 times.
✓ Branch 1 taken 2250270 times.
✓ Branch 2 taken 281356 times.
✓ Branch 3 taken 1968914 times.
✓ Branch 4 taken 304558 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 304558 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 38579 times.
✓ Branch 11 taken 265979 times.
✓ Branch 12 taken 11031 times.
✓ Branch 13 taken 27548 times.
✓ Branch 14 taken 10967 times.
✓ Branch 15 taken 64 times.
2273472 if(((dtype==dBOMBED)?DrunkDown():dir==down) && ((diagonalMovement||NO_GRIDLOCK)?x>112&&x<128:x==120) && y>=128 && tmpscr->door[1]==dtype)
9745 {
9746 64 walk=true;
9747 64 dir=down;
9748 64 }
9749
9750
10/14
✓ Branch 0 taken 23202 times.
✓ Branch 1 taken 2250270 times.
✓ Branch 2 taken 3306 times.
✓ Branch 3 taken 2246964 times.
✓ Branch 4 taken 26508 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 26508 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 13486 times.
✓ Branch 11 taken 13022 times.
✓ Branch 12 taken 13437 times.
✓ Branch 13 taken 49 times.
2273472 if(((dtype==dBOMBED)?DrunkLeft():dir==left) && x<=32 && ((diagonalMovement||NO_GRIDLOCK)?y>72&&y<88:y==80) && tmpscr->door[2]==dtype)
9751 {
9752 49 walk=true;
9753 49 dir=left;
9754 49 }
9755
9756
10/14
✓ Branch 0 taken 2250270 times.
✓ Branch 1 taken 23202 times.
✓ Branch 2 taken 8642 times.
✓ Branch 3 taken 2241628 times.
✓ Branch 4 taken 31844 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 31844 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 17839 times.
✓ Branch 11 taken 14005 times.
✓ Branch 12 taken 17781 times.
✓ Branch 13 taken 58 times.
2273472 if(((dtype==dBOMBED)?DrunkRight():dir==right) && x>=208 && ((diagonalMovement||NO_GRIDLOCK)?y>72&&y<88:y==80) && tmpscr->door[3]==dtype)
9757 {
9758 58 walk=true;
9759 58 dir=right;
9760 58 }
9761 2273472 }
9762
9763
2/2
✓ Branch 0 taken 3394679 times.
✓ Branch 1 taken 241 times.
3394920 if(walk)
9764 {
9765 241 hclk=0;
9766 241 drawguys=false;
9767
9768
2/2
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 68 times.
241 if(dtype==dWALK)
9769 {
9770 68 sfx(tmpscr->secretsfx);
9771 68 }
9772
9773 241 action=none; FFCore.setHeroAction(none);
9774 241 stepforward(29, true);
9775 241 action=scrolling; FFCore.setHeroAction(scrolling);
9776 241 pushing=false;
9777 241 }
9778
9779
4/6
✓ Branch 0 taken 66082 times.
✓ Branch 1 taken 3328838 times.
✓ Branch 2 taken 66082 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 66082 times.
3394920 if( game->get_life() <= (game->get_hp_per_heart()) && !(game->get_maxlife() <= (game->get_hp_per_heart())) && (heart_beep_timer > -3))
9780 {
9781
1/2
✓ Branch 0 taken 66082 times.
✗ Branch 1 not taken.
66082 if(heart_beep)
9782 {
9783 66082 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
9784 66082 }
9785 else
9786 {
9787 if ( heart_beep_timer == -1 )
9788 {
9789 heart_beep_timer = 70;
9790 }
9791
9792 if ( heart_beep_timer > 0 )
9793 {
9794 --heart_beep_timer;
9795 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
9796 }
9797 else
9798 {
9799 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
9800 }
9801 }
9802 66082 }
9803 else
9804 {
9805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3328838 times.
3328838 if ( heart_beep_timer > -2 )
9806 {
9807 3328838 heart_beep_timer = -1;
9808 3328838 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
9809 3328838 }
9810 }
9811
9812
2/2
✓ Branch 0 taken 3394406 times.
✓ Branch 1 taken 514 times.
3394920 if(rSbtn())
9813 {
9814 514 int32_t tmp_subscr_clk = frame;
9815
9816 514 int32_t save_type = 0;
9817
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 506 times.
✗ Branch 3 not taken.
514 switch(lsave)
9818 {
9819 case 0:
9820 {
9821
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 465 times.
506 if( FFCore.runActiveSubscreenScriptEngine() )
9822 {
9823 41 break;
9824 }
9825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 465 times.
465 else if ( !stopSubscreenFalling() )
9826 {
9827 465 conveyclk=3;
9828 465 dosubscr(&QMisc);
9829 465 newscr_clk += frame - tmp_subscr_clk;
9830 465 }
9831 465 break;
9832 }
9833
9834
9835 case 2:
9836 save_type = 1;
9837 [[fallthrough]];
9838 case 1:
9839
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(last_savepoint_id)
9840 7 trigger_save(combobuf[last_savepoint_id]);
9841 else save_game((tmpscr->flags4&fSAVEROOM) != 0, save_type); //sanity?
9842 7 break;
9843 }
9844 514 }
9845
9846
2/2
✓ Branch 0 taken 232712 times.
✓ Branch 1 taken 3162206 times.
3394918 if (!checkstab() )
9847 {
9848 /*
9849 for(int32_t q=0; q<176; q++)
9850 {
9851 set_bit(screengrid,q,0);
9852 }
9853
9854 for(int32_t q=0; q<MAXFFCS; q++)
9855 set_bit(ffcgrid, q, 0);
9856 */
9857 3162206 }
9858
9859 3394918 check_conveyor();
9860 3394918 PhantomsCleanup();
9861 //Try to time the hammer pound so that Hero can;t change direction while it occurs.
9862
2/2
✓ Branch 0 taken 3387462 times.
✓ Branch 1 taken 7456 times.
3394918 if(attack==wHammer)
9863 {
9864
5/8
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 7372 times.
✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 84 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 84 times.
7456 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
9865 {
9866
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 38 times.
84 switch(dir) //Hero's dir
9867 {
9868 case up:
9869
5/10
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 27 times.
✗ Branch 9 not taken.
27 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
9870 27 break;
9871
9872 case down:
9873
5/10
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 17 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 17 times.
✗ Branch 9 not taken.
17 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
9874 17 break;
9875
9876 case left:
9877
5/10
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
2 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
9878 2 break;
9879
9880 case right:
9881
5/10
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 38 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 38 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 38 times.
✗ Branch 9 not taken.
38 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
9882 38 break;
9883 }
9884
9885 84 }
9886 7456 }
9887
9888 3394918 handleSpotlights();
9889
9890
2/2
✓ Branch 0 taken 3394699 times.
✓ Branch 1 taken 219 times.
3394918 if(getOnSideviewLadder())
9891 {
9892
5/8
✓ Branch 0 taken 214 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 214 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 214 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 214 times.
219 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
9893 {
9894 5 setOnSideviewLadder(false);
9895 5 }
9896
4/8
✓ Branch 0 taken 214 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 174 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 40 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
214 else if(CANFORCEFACEUP)
9897 {
9898 40 setDir(up);
9899 40 }
9900 219 }
9901
2/2
✓ Branch 0 taken 3386004 times.
✓ Branch 1 taken 8914 times.
3394918 if (justmoved > 0) --justmoved;
9902
9903 3394918 return false;
9904 3395229 }
9905
9906 6470 bool HeroClass::push_pixel(zfix dx, zfix dy)
9907 {
9908
2/4
✓ Branch 0 taken 6470 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6470 times.
✗ Branch 3 not taken.
6470 ASSERT(abs(dx) <= 1 && abs(dy) <= 1);
9909
3/4
✓ Branch 0 taken 3456 times.
✓ Branch 1 taken 3014 times.
✓ Branch 2 taken 3456 times.
✗ Branch 3 not taken.
6470 if(dx && dy)
9910 {
9911 bool r = push_pixel(0,dy);
9912 bool r2 = push_pixel(dx,0);
9913 return r && r2;
9914 }
9915
2/2
✓ Branch 0 taken 3091 times.
✓ Branch 1 taken 3379 times.
6470 if(dx < 0)
9916 {
9917
1/2
✓ Branch 0 taken 3091 times.
✗ Branch 1 not taken.
6182 if(!(solpush_walkflag(x+dx,y+(bigHitbox?0:8),1,this)
9918
1/2
✓ Branch 0 taken 3091 times.
✗ Branch 1 not taken.
3091 || solpush_walkflag(x+dx,y+8,1,this)
9919
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3091 times.
✓ Branch 2 taken 2680 times.
✓ Branch 3 taken 411 times.
3091 || (y.getInt()&7?solpush_walkflag(x+dx,y+16,1,this):0)))
9920 {
9921 3091 x += dx;
9922 3091 return true;
9923 }
9924 return false;
9925 }
9926
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 3014 times.
3379 else if(dx > 0)
9927 {
9928
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
730 if(!(solpush_walkflag(x+15+dx,y+(bigHitbox?0:8),1,this)
9929
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
365 || solpush_walkflag(x+15+dx,y+8,1,this)
9930
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 365 times.
✓ Branch 2 taken 218 times.
✓ Branch 3 taken 147 times.
365 || (y.getInt()&7?solpush_walkflag(x+15+dx,y+16,1,this):0)))
9931 {
9932 365 x += dx;
9933 365 return true;
9934 }
9935 return false;
9936 }
9937
2/2
✓ Branch 0 taken 1757 times.
✓ Branch 1 taken 1257 times.
3014 else if(dy < 0)
9938 {
9939
1/2
✓ Branch 0 taken 1757 times.
✗ Branch 1 not taken.
3514 if(!(solpush_walkflag(x,y+(bigHitbox?0:8)+dy,2,this)
9940
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1757 times.
✓ Branch 2 taken 1623 times.
✓ Branch 3 taken 134 times.
1757 || (x.getInt()&7?solpush_walkflag(x+16,y+(bigHitbox?0:8)+dy,1,this):0)))
9941 {
9942 1757 y += dy;
9943 1757 return true;
9944 }
9945 return false;
9946 }
9947
1/2
✓ Branch 0 taken 1257 times.
✗ Branch 1 not taken.
1257 else if(dy > 0)
9948 {
9949
2/2
✓ Branch 0 taken 1220 times.
✓ Branch 1 taken 37 times.
2494 if(!(solpush_walkflag(x,y+15+dy,2,this)
9950
4/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1237 times.
✓ Branch 2 taken 224 times.
✓ Branch 3 taken 1013 times.
1257 || (x.getInt()&7?solpush_walkflag(x+16,y+15+dy,1,this):0)))
9951 {
9952 1220 y += dy;
9953 1220 return true;
9954 }
9955 37 return false;
9956 }
9957 return false;
9958 6470 }
9959 3407 int32_t HeroClass::push_move(zfix dx, zfix dy)
9960 {
9961 3407 int32_t ret = 0;
9962
4/4
✓ Branch 0 taken 3456 times.
✓ Branch 1 taken 4259 times.
✓ Branch 2 taken 3407 times.
✓ Branch 3 taken 4308 times.
7715 while(dx || dy)
9963 {
9964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4308 times.
4308 if(check_pitslide() != -1)
9965 break;
9966
2/2
✓ Branch 0 taken 1294 times.
✓ Branch 1 taken 3014 times.
4308 if(dy)
9967 {
9968
2/2
✓ Branch 0 taken 2128 times.
✓ Branch 1 taken 886 times.
3014 zfix cy = (abs(dy) >= 1) ? sign(dy) : dy;
9969 3014 dy -= cy;
9970
2/2
✓ Branch 0 taken 2977 times.
✓ Branch 1 taken 37 times.
3014 if(!push_pixel(0,cy))
9971 {
9972 37 dy = 0;
9973 37 ret |= 2;
9974 37 }
9975 3014 }
9976
2/2
✓ Branch 0 taken 852 times.
✓ Branch 1 taken 3456 times.
4308 if(dx)
9977 {
9978
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 2012 times.
3456 zfix cx = (abs(dx) >= 1) ? sign(dx) : dx;
9979 3456 dx -= cx;
9980
1/2
✓ Branch 0 taken 3456 times.
✗ Branch 1 not taken.
3456 if(!push_pixel(cx,0))
9981 {
9982 dx = 0;
9983 ret |= 1;
9984 }
9985 3456 }
9986 }
9987 3407 return ret;
9988 }
9989
9990 3395212 bool HeroClass::setSolid(bool set)
9991 {
9992
1/2
✓ Branch 0 taken 3395212 times.
✗ Branch 1 not taken.
3395212 bool actual = set && !toogam; //not solid when noclipping
9993 3395212 bool ret = solid_object::setSolid(actual);
9994 3395212 solid = set;
9995 3395212 return ret;
9996 }
9997
9998 13071 void HeroClass::solid_push(solid_object* obj)
9999 {
10000
1/2
✓ Branch 0 taken 13071 times.
✗ Branch 1 not taken.
13071 if(obj == this) return; //can't push self
10001
10002 13071 zfix dx, dy;
10003 13071 int32_t hdir = -1;
10004 13071 solid_push_int(obj,dx,dy,hdir);
10005
10006
4/4
✓ Branch 0 taken 12146 times.
✓ Branch 1 taken 925 times.
✓ Branch 2 taken 11881 times.
✓ Branch 3 taken 265 times.
13071 if(!dx && !dy) return;
10007
10008 1190 obj->doContactDamage(hdir);
10009
10010 1190 bool t = obj->getTempNonsolid();
10011 1190 obj->setTempNonsolid(true);
10012
10013 1190 push_move(dx,dy);
10014
10015 1190 obj->setTempNonsolid(t);
10016 13071 }
10017
10018 // A routine used exclusively by startwpn,
10019 // to switch Hero's weapon if his current weapon (bombs) was depleted.
10020 476 void HeroClass::deselectbombs(int32_t super)
10021 {
10022
6/10
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 471 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 471 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 471 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 471 times.
476 if ( get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) || itemsbuf[game->forced_awpn].family == itype_bomb || itemsbuf[game->forced_bwpn].family == itype_bomb || itemsbuf[game->forced_xwpn].family == itype_bomb || itemsbuf[game->forced_ywpn].family == itype_bomb) return;
10023
2/6
✓ Branch 0 taken 471 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 471 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
471 if(getItemFamily(itemsbuf,Bwpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Bwpn==directWpn))
10024 {
10025
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 471 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 471 times.
471 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10026 471 Bwpn = Bweapon(temp);
10027 471 directItemB = directItem;
10028 471 game->bwpn = temp;
10029 471 }
10030
10031 else if (getItemFamily(itemsbuf,Xwpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Xwpn==directWpn))
10032 {
10033 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->xwpn, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10034 Xwpn = Bweapon(temp);
10035 directItemX = directItem;
10036 game->xwpn = temp;
10037 }
10038 else if (getItemFamily(itemsbuf,Ywpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Ywpn==directWpn))
10039 {
10040 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->ywpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, game->awpn);
10041 Ywpn = Bweapon(temp);
10042 directItemY = directItem;
10043 game->ywpn = temp;
10044 }
10045 else
10046 {
10047 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10048 Awpn = Bweapon(temp);
10049 directItemA = directItem;
10050 game->awpn = temp;
10051 }
10052 476 }
10053
10054 int32_t potion_life=0;
10055 int32_t potion_magic=0;
10056
10057 bool HeroClass::mirrorBonk()
10058 {
10059 zfix tx = x, ty = y, tz = z;
10060 WalkflagInfo info = walkflag(x,y+(bigHitbox?0:8),2,up);
10061 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8));
10062 execute(info);
10063 bool fail = info.isUnwalkable();
10064
10065 if(!fail) //not solid, but check for water/pits...
10066 {
10067 //{ Check water collision.... GAAAAAAAH THIS IS A MESS
10068 int32_t water = 0;
10069 int32_t types[4] = {0};
10070 int32_t x1 = x+4, x2 = x+11,
10071 y1 = y+9, y2 = y+15;
10072 if (get_bit(quest_rules, qr_SMARTER_WATER))
10073 {
10074 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
10075 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
10076 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
10077 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
10078 }
10079 else
10080 {
10081 types[0] = COMBOTYPE(x1,y1);
10082
10083 if(MAPFFCOMBO(x1,y1))
10084 types[0] = FFCOMBOTYPE(x1,y1);
10085
10086 types[1] = COMBOTYPE(x1,y2);
10087
10088 if(MAPFFCOMBO(x1,y2))
10089 types[1] = FFCOMBOTYPE(x1,y2);
10090
10091 types[2] = COMBOTYPE(x2,y1);
10092
10093 if(MAPFFCOMBO(x2,y1))
10094 types[2] = FFCOMBOTYPE(x2,y1);
10095
10096 types[3] = COMBOTYPE(x2,y2);
10097
10098 if(MAPFFCOMBO(x2,y2))
10099 types[3] = FFCOMBOTYPE(x2,y2);
10100
10101 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
10102 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
10103 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
10104
10105 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
10106 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
10107 water = typec;
10108 }
10109 if(water > 0)
10110 {
10111 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
10112 {
10113 fail = true;
10114 }
10115 }
10116 //}
10117 if(pitslide() || fallclk)
10118 fail = true;
10119 fallclk = 0;
10120 }
10121 x = tx; y = ty; z = tz;
10122 return fail;
10123 }
10124
10125 void HeroClass::doMirror(int32_t mirrorid)
10126 {
10127 if(z > 0 || fakez > 0) return; //No mirror in air
10128 if(mirrorid < 0)
10129 mirrorid = current_item_id(itype_mirror);
10130 if(mirrorid < 0) return;
10131
10132 if((tmpscr->flags9&fDISABLE_MIRROR) || !(checkbunny(mirrorid) && checkmagiccost(mirrorid)))
10133 {
10134 item_error();
10135 return;
10136 }
10137 static const int32_t sens = 4; //sensitivity of 'No Mirror' combos (0 most, 8 least)
10138 int32_t posarr[] = {COMBOPOS(x+sens,y+sens), COMBOPOS(x+sens,y+15-sens),
10139 COMBOPOS(x+15-sens,y+sens), COMBOPOS(x+15-sens,y+15-sens)};
10140 for(auto pos : posarr)
10141 {
10142 if(HASFLAG_ANY(mfNOMIRROR, pos)) //"No Mirror" flag touching the player
10143 {
10144 item_error();
10145 return;
10146 }
10147 }
10148
10149 itemdata const& mirror = itemsbuf[mirrorid];
10150 if(DMaps[currdmap].flags & dmfMIRRORCONTINUE)
10151 {
10152 paymagiccost(mirrorid);
10153 if(mirror.usesound2) sfx(mirror.usesound2);
10154
10155 doWarpEffect(mirror.misc2, true);
10156 if(mirror.flags & ITEM_FLAG2) //Act as F6->Continue
10157 {
10158 Quit = qCONT;
10159 skipcont = 1;
10160 }
10161 else //Act as Farore's Wind
10162 {
10163 int32_t nayrutemp=nayruitem;
10164 restart_level();
10165 nayruitem=nayrutemp;
10166 magicitem=-1;
10167 magiccastclk=0;
10168 if ( Hero.getDontDraw() < 2 ) { Hero.setDontDraw(0); }
10169 }
10170 }
10171 else
10172 {
10173 int32_t destdmap = DMaps[currdmap].mirrorDMap;
10174 int32_t offscr = currscr - DMaps[currdmap].xoff;
10175 if(destdmap < 0)
10176 return;
10177 int32_t destscr = DMaps[destdmap].xoff + offscr;
10178 if((offscr%16 != destscr%16) || unsigned(destscr) >= 0x80)
10179 return;
10180 paymagiccost(mirrorid);
10181
10182 //Store some values to restore if 'warp fails'
10183 int32_t tLastEntrance = lastentrance,
10184 tLastEntranceDMap = lastentrance_dmap,
10185 tContScr = game->get_continue_scrn(),
10186 tContDMap = game->get_continue_dmap(),
10187 tPortalDMap = game->portalsrcdmap;
10188 int32_t sourcescr = currscr, sourcedmap = currdmap;
10189 zfix tx = x, ty = y, tz = z;
10190 game->portalsrcdmap = -1;
10191 action = none; FFCore.setHeroAction(none);
10192
10193 //Warp to new dmap
10194 FFCore.warp_player(wtIWARP, destdmap, destscr, -1, -1, mirror.misc1,
10195 mirror.usesound, 0, -1);
10196
10197 //Check for valid landing location
10198 if(mirrorBonk()) //Invalid landing, warp back!
10199 {
10200 action = none; FFCore.setHeroAction(none);
10201 lastentrance = tLastEntrance;
10202 lastentrance_dmap = tLastEntranceDMap;
10203 game->set_continue_scrn(tContScr);
10204 game->set_continue_dmap(tContDMap);
10205 x = tx;
10206 y = ty;
10207 z = tz;
10208 game->portalsrcdmap = tPortalDMap;
10209 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, mirror.misc1,
10210 mirror.usesound, 0, -1);
10211 }
10212 else if(mirror.flags & ITEM_FLAG1) //Place portal!
10213 {
10214 //Place the portal
10215 game->set_portal(sourcedmap, destdmap, offscr, x.getZLong(), y.getZLong(), mirror.usesound, mirror.misc1, mirror.wpn);
10216 //Since it was placed after loading this screen, load the portal object now
10217 game->load_portal();
10218 //Don't immediately trigger the warp back
10219 can_mirror_portal = false;
10220
10221 //Set continue point
10222 if(currdmap != game->get_continue_dmap())
10223 {
10224 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
10225 }
10226 game->set_continue_dmap(currdmap);
10227 lastentrance_dmap = currdmap;
10228 lastentrance = game->get_continue_scrn();
10229 }
10230 }
10231 }
10232
10233 3394924 void HeroClass::handle_passive_buttons()
10234 {
10235 3394924 do_liftglove(-1,true);
10236 3394924 do_jump(-1,true);
10237 3394924 }
10238
10239 static bool did_passive_jump = false;
10240 3394991 bool HeroClass::do_jump(int32_t jumpid, bool passive)
10241 {
10242
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 3394924 times.
3394991 if(passive) did_passive_jump = false;
10243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 else if(did_passive_jump) return false; //don't jump twice in the same frame
10244
10245
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 3394924 times.
3394991 if(jumpid < 0)
10246 3394924 jumpid = current_item_id(itype_rocs,true,true);
10247
10248
2/2
✓ Branch 0 taken 3209585 times.
✓ Branch 1 taken 185406 times.
3394991 if(unsigned(jumpid) >= MAXITEMS) return false;
10249
4/4
✓ Branch 0 taken 185295 times.
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 1411 times.
✓ Branch 3 taken 183884 times.
185406 if(inlikelike || charging) return false;
10250
1/2
✓ Branch 0 taken 183884 times.
✗ Branch 1 not taken.
183884 if(!checkitem_jinx(jumpid)) return false;
10251
10252 183884 itemdata const& itm = itemsbuf[jumpid];
10253
10254 183884 bool standing = isStanding(true);
10255
3/4
✓ Branch 0 taken 181539 times.
✓ Branch 1 taken 2345 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2345 times.
183884 bool coyotejump = !standing && coyotetime < (zc_min(65535,itm.misc5));
10256
4/6
✓ Branch 0 taken 183884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2345 times.
✓ Branch 3 taken 181539 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2345 times.
183884 if(!(coyotejump || standing || extra_jump_count < itm.misc1)) return false;
10257
2/4
✓ Branch 0 taken 181539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 181539 times.
181539 if(!(checkbunny(jumpid) && checkmagiccost(jumpid)))
10258 {
10259 item_error();
10260 return false;
10261 }
10262
10263 181539 byte intbtn = byte(itm.misc2&0xFF);
10264
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 181478 times.
181539 if(passive)
10265 {
10266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 181478 times.
181478 if(!getIntBtnInput(intbtn, true, true, false, false, true))
10267 181478 return false; //not pressed
10268 }
10269
10270 61 paymagiccost(jumpid);
10271
10272
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if(!standing)
10273 {
10274 ++extra_jump_count;
10275 fall = 0;
10276 fakefall = 0;
10277 if(hoverclk > 0)
10278 hoverclk = -hoverclk;
10279 }
10280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(itm.flags & ITEM_FLAG1)
10281 setFall(fall - itm.power);
10282 61 else setFall(fall - (FEATHERJUMP*(itm.power+2)));
10283 61 coyotetime = 65535; //jumped, so no coyotetime
10284 61 setOnSideviewLadder(false);
10285
10286 // Reset the ladder, unless on an unwalkable combo
10287
3/10
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 61 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 61 times.
✗ Branch 9 not taken.
61 if((ladderx || laddery) && !(_walkflag(ladderx,laddery,0,SWITCHBLOCK_STATE)))
10288 reset_ladder();
10289
10290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(itm.usesound)
10291 61 sfx(itm.usesound,pan(x.getInt()));
10292
10293
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if(passive) did_passive_jump = true;
10294 61 return true;
10295 3394991 }
10296 928 void HeroClass::drop_liftwpn()
10297 {
10298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 928 times.
928 if(!lift_wpn) return;
10299
10300 handle_lift(false); //sets position properly, accounting for large weapons
10301 auto liftid = current_item_id(itype_liftglove,true,true);
10302 itemdata const& glove = itemsbuf[liftid];
10303 if(glove.flags & ITEM_FLAG1)
10304 {
10305 lift_wpn->z = 0;
10306 lift_wpn->fakez = liftheight;
10307 }
10308 else lift_wpn->z = liftheight;
10309 lift_wpn->dir = dir;
10310 lift_wpn->step = 0;
10311 lift_wpn->fakefall = 0;
10312 lift_wpn->fall = 0;
10313 if(glove.flags & ITEM_FLAG1)
10314 lift_wpn->moveflags |= FLAG_NO_REAL_Z;
10315 else
10316 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
10317 Lwpns.add(lift_wpn);
10318 lift_wpn = nullptr;
10319 928 }
10320 3394924 void HeroClass::do_liftglove(int32_t liftid, bool passive)
10321 {
10322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3394924 times.
3394924 if(liftid < 0)
10323 3394924 liftid = current_item_id(itype_liftglove,true,true);
10324
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 3394060 times.
3394924 if(!can_lift(liftid)) return;
10325 864 itemdata const& glove = itemsbuf[liftid];
10326 864 byte intbtn = byte(glove.misc1&0xFF);
10327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
864 if(passive)
10328 {
10329
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 855 times.
864 if(!getIntBtnInput(intbtn, true, true, false, false, true))
10330 855 return; //not pressed
10331 9 }
10332
10333 9 bool had_weapon = lift_wpn;
10334
10335
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
18 if(!(had_weapon || //Allow throwing while bunnied/don't charge magic for throwing
10336
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (checkbunny(liftid) && checkmagiccost(liftid))))
10337 {
10338 item_error();
10339 return;
10340 }
10341
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9 if(glove.script!=0 && (item_doscript[liftid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
10342 return;
10343
10344 9 bool paidmagic = had_weapon; //don't pay to throw, only to lift
10345
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(glove.script)
10346 {
10347 if(!paidmagic)
10348 {
10349 paidmagic = true;
10350 paymagiccost(liftid);
10351 }
10352
10353 ri = &(itemScriptData[liftid]);
10354 for ( int32_t q = 0; q < 1024; q++ )
10355 item_stack[liftid][q] = 0xFFFF;
10356 ri->Clear();
10357 item_doscript[liftid] = 1;
10358 itemscriptInitialised[liftid] = 0;
10359 ZScriptVersion::RunScript(SCRIPT_ITEM, glove.script, liftid);
10360
10361 bool has_weapon = lift_wpn;
10362 if(has_weapon != had_weapon) //Item action script changed the lift information
10363 {
10364 if(passive)
10365 {
10366 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10367 }
10368 return;
10369 }
10370 }
10371
10372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(lift_wpn)
10373 {
10374 if(!paidmagic)
10375 {
10376 paidmagic = true;
10377 paymagiccost(liftid);
10378 }
10379 if(!liftclk)
10380 {
10381 //Throw the weapon!
10382 //hero's direction and position
10383 handle_lift(false); //sets position properly, accounting for large weapons
10384 if(glove.flags & ITEM_FLAG1)
10385 {
10386 lift_wpn->z = 0;
10387 lift_wpn->fakez = liftheight;
10388 }
10389 else lift_wpn->z = liftheight;
10390 lift_wpn->dir = dir;
10391 //Configured throw speed in both axes
10392 lift_wpn->step = zfix(glove.misc2)/100;
10393 if(glove.flags & ITEM_FLAG1)
10394 {
10395 lift_wpn->fakefall = -glove.misc3;
10396 lift_wpn->moveflags |= FLAG_NO_REAL_Z;
10397 }
10398 else
10399 {
10400 lift_wpn->fall = -glove.misc3;
10401 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
10402 }
10403 Lwpns.add(lift_wpn);
10404 lift_wpn = nullptr;
10405 if(glove.usesound2)
10406 sfx(glove.usesound2,pan(int32_t(x)));
10407 }
10408
10409 if(passive)
10410 {
10411 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10412 }
10413 return;
10414 }
10415
10416 //Check for a liftable combo
10417 9 zfix bx, by;
10418 9 zfix bx2, by2;
10419
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
9 switch(dir)
10420 {
10421 case up:
10422 9 by = y + (bigHitbox ? -2 : 6);
10423 9 by2 = by;
10424 9 bx = x + 4;
10425 9 bx2 = bx + 8;
10426 9 break;
10427 case down:
10428 by = y + 17;
10429 by2 = by;
10430 bx = x + 4;
10431 bx2 = bx + 8;
10432 break;
10433 case left:
10434 by = y + (bigHitbox ? 0 : 8);
10435 by2 = y + 8;
10436 bx = x - 2;
10437 bx2 = x - 2;
10438 break;
10439 case right:
10440 by = y + (bigHitbox ? 0 : 8);
10441 by2 = y + 8;
10442 bx = x + 17;
10443 bx2 = x + 17;
10444 break;
10445 }
10446 9 int32_t pos = COMBOPOS_B(bx,by);
10447 9 int32_t pos2 = COMBOPOS_B(bx2,by2);
10448 9 int32_t foundpos = -1;
10449
10450 9 bool lifted = false;
10451
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 63 times.
72 for(auto lyr = 6; lyr >= 0; --lyr)
10452 {
10453 63 mapscr* scr = FFCore.tempScreens[lyr];
10454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(pos > -1)
10455 {
10456 63 newcombo const& cmb = combobuf[scr->data[pos]];
10457
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(cmb.liftflags & LF_LIFTABLE)
10458 {
10459 if(do_lift_combo(lyr,pos,liftid))
10460 {
10461 lifted = true;
10462 break;
10463 }
10464 }
10465 63 }
10466
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
63 if(pos != pos2 && pos2 > -1)
10467 {
10468 63 newcombo const& cmb2 = combobuf[scr->data[pos2]];
10469
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(cmb2.liftflags & LF_LIFTABLE)
10470 {
10471 if(do_lift_combo(lyr,pos2,liftid))
10472 {
10473 lifted = true;
10474 break;
10475 }
10476 }
10477 63 }
10478 63 }
10479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!lifted) return;
10480 if(!paidmagic)
10481 {
10482 paidmagic = true;
10483 paymagiccost(liftid);
10484 }
10485 if(passive)
10486 {
10487 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10488 }
10489 return;
10490 3394924 }
10491 void HeroClass::handle_lift(bool dec)
10492 {
10493 lift_wpn->fakez = 0;
10494 if(!lift_wpn) liftclk = 0;
10495 if(liftclk <= (dec?1:0))
10496 {
10497 liftclk = 0;
10498 tliftclk = 0;
10499 if(lift_wpn)
10500 {
10501 if(lift_wpn->txsz > 1 || lift_wpn->tysz > 1)
10502 {
10503 lift_wpn->x = x+8 - (lift_wpn->txsz*8);
10504 lift_wpn->y = y+8 - (lift_wpn->tysz*8);
10505 }
10506 else
10507 {
10508 lift_wpn->x = x;
10509 lift_wpn->y = y;
10510 }
10511 lift_wpn->z = liftheight;
10512 }
10513 if(action == lifting)
10514 {
10515 action = none; FFCore.setHeroAction(none);
10516 }
10517 return;
10518 }
10519 if(dec) --liftclk;
10520 double xdist, ydist;
10521 double perc = (liftclk/double(tliftclk));
10522 switch(dir)
10523 {
10524 case up:
10525 {
10526 xdist = 0;
10527 ydist = -16;
10528 if(lift_wpn->txsz > 1)
10529 {
10530 xdist = -((lift_wpn->txsz*8)-8);
10531 }
10532 else xdist = 0;
10533 if(lift_wpn->tysz > 1)
10534 {
10535 ydist = -(lift_wpn->tysz*16);
10536 }
10537 ydist *= perc;
10538 break;
10539 }
10540 case down:
10541 {
10542 xdist = 0;
10543 ydist = 16;
10544 if(lift_wpn->txsz > 1)
10545 {
10546 xdist = -((lift_wpn->txsz*8)-8);
10547 }
10548 else xdist = 0;
10549 ydist *= perc;
10550 break;
10551 }
10552 case left:
10553 {
10554 xdist = -16;
10555 ydist = 0;
10556 if(lift_wpn->txsz > 1)
10557 {
10558 xdist = -(lift_wpn->txsz*16);
10559 }
10560 if(lift_wpn->tysz > 1)
10561 {
10562 ydist = -((lift_wpn->tysz*8)-8);
10563 }
10564 else ydist = 0;
10565 xdist *= perc;
10566 break;
10567 }
10568 case right:
10569 {
10570 xdist = 16;
10571 ydist = 0;
10572 if(lift_wpn->tysz > 1)
10573 {
10574 ydist = -((lift_wpn->tysz*8)-8);
10575 }
10576 else ydist = 0;
10577 xdist *= perc;
10578 break;
10579 }
10580 }
10581
10582 lift_wpn->x = x + xdist;
10583 lift_wpn->y = y + ydist;
10584 lift_wpn->z = liftheight*(1.0-perc);
10585 }
10586 3394924 bool HeroClass::can_lift(int32_t gloveid)
10587 {
10588
2/2
✓ Branch 0 taken 3394060 times.
✓ Branch 1 taken 864 times.
3394924 if(unsigned(gloveid) >= MAXITEMS) return false;
10589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
864 if(lstunclock) return false;
10590
1/2
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
864 if(!checkitem_jinx(gloveid)) return false;
10591 864 itemdata const& glove = itemsbuf[gloveid];
10592
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
✗ Branch 2 not taken.
864 switch(action)
10593 {
10594 case none: case walking:
10595 864 break;
10596
10597 case swimming:
10598 if(glove.flags & ITEM_FLAG2)
10599 break;
10600 return false;
10601
10602 default:
10603 return false;
10604 }
10605 864 return true;
10606 3394924 }
10607 void HeroClass::lift(weapon* w, byte timer, zfix height)
10608 {
10609 lift_wpn = w;
10610 liftclk = timer;
10611 tliftclk = timer;
10612 if(height < 0)
10613 liftheight = 0;
10614 else liftheight = height;
10615 }
10616
10617 void HeroClass::doSwitchHook(byte style)
10618 {
10619 hs_switcher = true;
10620 pull_hero = true;
10621 //{ Load hook weapons, set them to obey special drawing
10622 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
10623 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
10624
10625 if(w)
10626 w->switch_hooked = true;
10627 if(hw)
10628 hw->switch_hooked = true;
10629 for(int32_t j=0; j<chainlinks.Count(); j++)
10630 {
10631 chainlinks.spr(j)->switch_hooked = true;
10632 }
10633 //}
10634 if(hooked_combopos > -1)
10635 {
10636 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
10637 hooked_layerbits = 0;
10638 for(auto q = 0; q < 7; ++q)
10639 hooked_undercombos[q] = -1;
10640 uint16_t plpos = COMBOPOS(x+8,y+8);
10641 for(auto q = max_layer; q > -1; --q)
10642 {
10643 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[hooked_combopos]];
10644 newcombo const& comb2 = combobuf[FFCore.tempScreens[q]->data[plpos]];
10645 int32_t fl1 = FFCore.tempScreens[q]->sflag[hooked_combopos],
10646 fl2 = FFCore.tempScreens[q]->sflag[plpos];
10647 bool isPush = false;
10648 if(isSwitchHookable(cmb))
10649 {
10650 if(cmb.type == cSWITCHHOOK)
10651 {
10652 uint16_t plpos = COMBOPOS(x+8,y+8);
10653 if((cmb.usrflags&cflag1) && FFCore.tempScreens[q]->data[plpos])
10654 continue; //don't swap with non-zero combo
10655 if(zc_max(1,itemsbuf[(w && w->parentitem>-1) ? w->parentitem : current_item_id(itype_switchhook)].fam_type) < cmb.attribytes[0])
10656 continue; //too low a switchhook level
10657 hooked_layerbits |= 1<<q; //Swapping
10658 if(cmb.usrflags&cflag3)
10659 {
10660 if(cmb.usrflags&cflag6)
10661 {
10662 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
10663 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
10664 }
10665 else
10666 {
10667 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
10668 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
10669 }
10670 }
10671 else
10672 {
10673 hooked_layerbits |= 1<<(q+8); //Swapping BACK
10674 if(cmb.usrflags&cflag7) //counts as 'pushblock'
10675 isPush = true;
10676 }
10677 }
10678 else if(isCuttableType(cmb.type))
10679 {
10680 if(isCuttableNextType(cmb.type))
10681 {
10682 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
10683 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
10684 }
10685 else
10686 {
10687 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
10688 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
10689 }
10690 hooked_layerbits |= 1<<q; //Swapping
10691 }
10692 else
10693 {
10694 hooked_layerbits |= 1<<q; //Swapping
10695 hooked_layerbits |= 1<<(q+8); //Swapping BACK
10696 }
10697 }
10698 if(hooked_layerbits & (1<<(q+8))) //2-way swap, check for pushblocks
10699 {
10700 if((cmb.type==cPUSH_WAIT || cmb.type==cPUSH_HW || cmb.type==cPUSH_HW2)
10701 && hasMainGuy())
10702 {
10703 hooked_layerbits &= ~(0x101<<q); //Can't swap yet
10704 continue;
10705 }
10706 if(fl1 == mfPUSHED)
10707 {
10708 hooked_layerbits &= ~(0x101<<q); //Can't swap at all, locked in place
10709 continue;
10710 }
10711 if(!isPush) switch(fl1)
10712 {
10713 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
10714 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
10715 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
10716 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
10717 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
10718 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
10719 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
10720 isPush = true;
10721 }
10722 if(!isPush) switch(cmb.flag)
10723 {
10724 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
10725 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
10726 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
10727 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
10728 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
10729 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
10730 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
10731 isPush = true;
10732 }
10733 if(isPush) //Check for block holes / triggers
10734 {
10735 if(comb2.flag == mfBLOCKHOLE || fl2 == mfBLOCKHOLE
10736 || comb2.flag == mfBLOCKTRIGGER || fl2 == mfBLOCKTRIGGER)
10737 {
10738 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10739 }
10740 else if(!get_bit(quest_rules, qr_BLOCKHOLE_SAME_ONLY))
10741 {
10742 auto maxLayer = get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2) ? 2 : 0;
10743 for(auto lyr = 0; lyr < maxLayer; ++lyr)
10744 {
10745 if(lyr == q) continue;
10746 switch(FFCore.tempScreens[q]->sflag[plpos])
10747 {
10748 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
10749 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10750 lyr=7;
10751 break;
10752 }
10753 switch(combobuf[FFCore.tempScreens[q]->data[plpos]].flag)
10754 {
10755 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
10756 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10757 lyr=7;
10758 break;
10759 }
10760 }
10761 }
10762 }
10763 }
10764 }
10765 }
10766 switch_hooked = true;
10767 switchhookstyle = style;
10768 switch(style)
10769 {
10770 default: case swPOOF:
10771 {
10772 wpndata const& spr = wpnsbuf[QMisc.sprites[sprSWITCHPOOF]];
10773 switchhookmaxtime = switchhookclk = zc_max(spr.frames,1) * zc_max(spr.speed,1);
10774 decorations.add(new comboSprite(x, y, 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10775 if(hooked_combopos > -1)
10776 decorations.add(new comboSprite((zfix)COMBOX(hooked_combopos), (zfix)COMBOY(hooked_combopos), 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10777 else if(switching_object)
10778 decorations.add(new comboSprite(switching_object->x, switching_object->y, 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10779 break;
10780 }
10781 case swFLICKER:
10782 {
10783 switchhookmaxtime = switchhookclk = 64;
10784 break;
10785 }
10786 case swRISE:
10787 {
10788 switchhookmaxtime = switchhookclk = 64;
10789 break;
10790 }
10791 }
10792 }
10793
10794 17513 bool HeroClass::startwpn(int32_t itemid)
10795 {
10796
1/2
✓ Branch 0 taken 17513 times.
✗ Branch 1 not taken.
17513 if(itemid < 0) return false;
10797 17513 itemdata const& itm = itemsbuf[itemid];
10798
5/6
✓ Branch 0 taken 3871 times.
✓ Branch 1 taken 13642 times.
✓ Branch 2 taken 3426 times.
✓ Branch 3 taken 10216 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 28 times.
17541 if(((dir==up && y<24) || (dir==down && y>128) ||
10799
6/6
✓ Branch 0 taken 5183 times.
✓ Branch 1 taken 5033 times.
✓ Branch 2 taken 5029 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 28 times.
✓ Branch 5 taken 17481 times.
17513 (dir==left && x<32) || (dir==right && x>208)) && !(get_bit(quest_rules,qr_ITEMSONEDGES) || inlikelike))
10800 28 return false;
10801
10802 17485 int32_t wx=x;
10803 17485 int32_t wy=y-fakez;
10804 17485 int32_t wz=z;
10805 17485 bool ret = true;
10806
10807
5/5
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3863 times.
✓ Branch 2 taken 3419 times.
✓ Branch 3 taken 5174 times.
✓ Branch 4 taken 5025 times.
17485 switch(dir)
10808 {
10809 case up:
10810 3863 wy-=16;
10811 3863 break;
10812
10813 case down:
10814 3419 wy+=16;
10815 3419 break;
10816
10817 case left:
10818 5174 wx-=16;
10819 5174 break;
10820
10821 case right:
10822 5025 wx+=16;
10823 5025 break;
10824 }
10825
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17485 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17485 if (IsSideSwim() && (itm.flags & ITEM_SIDESWIM_DISABLED)) return false;
10826
10827
14/27
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 174 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 67 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 114 times.
✓ Branch 11 taken 464 times.
✓ Branch 12 taken 12 times.
✓ Branch 13 taken 1198 times.
✓ Branch 14 taken 8777 times.
✓ Branch 15 taken 896 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 378 times.
✓ Branch 18 taken 6 times.
✓ Branch 19 taken 5343 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
17485 switch(itm.family)
10828 {
10829 case itype_liftglove:
10830 {
10831 do_liftglove(itemid,false);
10832 dowpn = -1;
10833 ret = false;
10834 break;
10835 }
10836 case itype_potion:
10837 {
10838
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20 times.
20 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
10839 {
10840 return item_error();
10841 }
10842
10843 20 paymagiccost(itemid);
10844
10845
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20 if(itm.misc1 || itm.misc2)
10846 {
10847 20 refill_what=REFILL_ALL;
10848 20 refill_why=itemid;
10849 20 StartRefill(REFILL_ALL);
10850 20 potion_life = game->get_life();
10851 20 potion_magic = game->get_magic();
10852
10853 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
10854 //music_pause();
10855 20 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
10856
2/2
✓ Branch 0 taken 4434 times.
✓ Branch 1 taken 20 times.
4454 while(refill())
10857 {
10858 4434 do_refill_waitframe();
10859 }
10860
10861 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
10862 //music_resume();
10863 20 ret = false;
10864 20 }
10865
10866 20 break;
10867 }
10868 case itype_bottle:
10869 {
10870 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
10871 {
10872 return item_error();
10873 }
10874 if(itm.script!=0 && (item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
10875 return false;
10876
10877 size_t bind = game->get_bottle_slot(itm.misc1);
10878 bool paidmagic = false;
10879 if(itm.script)
10880 {
10881 paidmagic = true;
10882 paymagiccost(itemid);
10883
10884 ri = &(itemScriptData[itemid]);
10885 for ( int32_t q = 0; q < 1024; q++ )
10886 item_stack[itemid][q] = 0xFFFF;
10887 ri->Clear();
10888 item_doscript[itemid] = 1;
10889 itemscriptInitialised[itemid] = 0;
10890 ZScriptVersion::RunScript(SCRIPT_ITEM, itm.script, itemid);
10891 bind = game->get_bottle_slot(itm.misc1);
10892 }
10893 bottletype const* bt = bind ? &(QMisc.bottle_types[bind-1]) : NULL;
10894 if(bt)
10895 {
10896 word toFill[3] = { 0 };
10897 for(size_t q = 0; q < 3; ++q)
10898 {
10899 char c = bt->counter[q];
10900 if(c > -1)
10901 {
10902 if(bt->flags & (1<<q))
10903 {
10904 toFill[q] = (bt->amount[q]==100)
10905 ? game->get_maxcounter(c)
10906 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
10907 }
10908 else toFill[q] = bt->amount[q];
10909 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
10910 {
10911 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
10912 }
10913 }
10914 }
10915 word max = std::max(toFill[0], std::max(toFill[1], toFill[2]));
10916 bool run = max > 0;
10917 if(get_bit(quest_rules, qr_NO_BOTTLE_IF_ANY_COUNTER_FULL))
10918 run = ((bt->counter[0] > -1 && !toFill[0]) || (bt->counter[1] > -1 && !toFill[1]) || (bt->counter[2] > -1 && !toFill[2]));
10919 else
10920 {
10921 if((bt->flags & BTFLAG_CURESWJINX) && swordclk)
10922 run = true;
10923 else if((bt->flags & BTFLAG_CUREITJINX) && itemclk)
10924 run = true;
10925 }
10926 if(run || (bt->flags&BTFLAG_ALLOWIFFULL))
10927 {
10928 if(bt->flags & BTFLAG_CURESWJINX)
10929 {
10930 swordclk = 0;
10931 verifyAWpn();
10932 }
10933 if(bt->flags & BTFLAG_CUREITJINX)
10934 itemclk = 0;
10935 if(!paidmagic)
10936 paymagiccost(itemid);
10937 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
10938 sfx(itm.usesound,pan(x.getInt()));
10939 for(size_t q = 0; q < 20; ++q)
10940 do_refill_waitframe();
10941 double inc = max/60.0; //1 second
10942 double xtra[3]{ 0 };
10943 for(size_t q = 0; q < 60; ++q)
10944 {
10945 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
10946 sfx(QMisc.miscsfx[sfxREFILL]);
10947 for(size_t j = 0; j < 3; ++j)
10948 {
10949 xtra[j] += inc;
10950 word f = floor(xtra[j]);
10951 xtra[j] -= f;
10952 if(toFill[j] > f)
10953 {
10954 toFill[j] -= f;
10955 game->change_counter(f,bt->counter[j]);
10956 }
10957 else if(toFill[j])
10958 {
10959 game->change_counter(toFill[j],bt->counter[j]);
10960 toFill[j] = 0;
10961 }
10962 }
10963 do_refill_waitframe();
10964 }
10965 for(size_t j = 0; j < 3; ++j)
10966 {
10967 if(toFill[j])
10968 {
10969 game->change_counter(toFill[j],bt->counter[j]);
10970 toFill[j] = 0;
10971 }
10972 }
10973 for(size_t q = 0; q < 20; ++q)
10974 do_refill_waitframe();
10975 game->set_bottle_slot(itm.misc1, bt->next_type);
10976 }
10977 }
10978
10979 dowpn = -1;
10980 ret = false;
10981 break;
10982 }
10983
10984 case itype_note:
10985 {
10986 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
10987 {
10988 return item_error();
10989 }
10990 if(!msg_active && itm.misc1 > 0 && itm.misc1 < MAXMSGS)
10991 {
10992 sfx(itm.usesound);
10993 donewmsg(itm.misc1);
10994 paymagiccost(itemid);
10995 }
10996 dowpn = -1;
10997 ret = false;
10998 break;
10999 }
11000
11001 case itype_mirror:
11002 doMirror(itemid);
11003 if(Quit)
11004 return false;
11005 ret = false;
11006 break;
11007
11008 case itype_rocs:
11009 {
11010
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 6 times.
67 if(!do_jump(itemid,false)) return false;
11011 61 ret = false;
11012 }
11013 61 break;
11014
11015 case itype_letter:
11016 {
11017
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 if(current_item(itype_letter)==i_letter &&
11018
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 tmpscr[currscr<128?0:1].room==rP_SHOP &&
11019
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 tmpscr[currscr<128?0:1].guy &&
11020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 ((currscr<128&&!(DMaps[currdmap].flags&dmfGUYCAVES))
11021
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 ||(currscr>=128&&DMaps[currdmap].flags&dmfGUYCAVES)) &&
11022 3 checkbunny(itemid)
11023 )
11024 {
11025 3 int32_t usedid = getItemID(itemsbuf, itype_letter,i_letter+1);
11026
11027
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(usedid != -1)
11028 3 getitem(usedid, true, true);
11029
11030 3 sfx(tmpscr[currscr<128?0:1].secretsfx);
11031 3 setupscreen();
11032 3 action=none; FFCore.setHeroAction(none);
11033 3 }
11034
11035 3 ret = false;
11036 }
11037 3 break;
11038
11039 case itype_whistle:
11040 {
11041 bool whistleflag;
11042
11043
4/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 106 times.
114 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11044 {
11045 8 return item_error();
11046 }
11047
11048 106 paymagiccost(itemid);
11049 106 sfx(itm.usesound);
11050
11051
4/4
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 49 times.
106 if(dir==up || dir==right)
11052 57 ++blowcnt;
11053 else
11054 49 --blowcnt;
11055
11056 106 int sfx_count = 0;
11057
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 19906 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 19910 times.
✓ Branch 6 taken 19800 times.
✓ Branch 7 taken 114 times.
19906 while ((!replay_is_active() && sfx_allocated(itm.usesound)) || (replay_is_active() && sfx_count < 180))
11058 {
11059 19800 sfx_count += 1;
11060 19800 advanceframe(true);
11061
11062
1/2
✓ Branch 0 taken 19800 times.
✗ Branch 1 not taken.
19800 if(Quit)
11063 return false;
11064 }
11065
11066
9/14
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 110 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 110 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 110 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 114 times.
✓ Branch 13 taken 4 times.
114 Lwpns.add(new weapon(x,y-fakez,z,wWhistle,0,0,dir,itemid,getUID(),false,0,1,0));
11067
11068
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if((whistleflag=findentrance(x,y,mfWHISTLE,get_bit(quest_rules, qr_PERMANENT_WHISTLE_SECRETS))))
11069 9 didstuff |= did_whistle;
11070
11071
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 103 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 103 times.
114 if((didstuff&did_whistle && itm.flags&ITEM_FLAG1) || currscr>=128)
11072 11 return false;
11073
11074
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 99 times.
103 if(itm.flags&ITEM_FLAG1) didstuff |= did_whistle;
11075
11076
4/4
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 77 times.
103 if((tmpscr->flags&fWHISTLE) || (tmpscr->flags7 & fWHISTLEWATER)
11077
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 || (tmpscr->flags7&fWHISTLEPAL))
11078 {
11079 26 whistleclk=0; // signal to start drying lake or doing other stuff
11080 26 }
11081 else
11082 {
11083 77 int32_t where = itm.misc1;
11084
11085
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(where>right) where=dir^1;
11086
11087
5/6
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 42 times.
119 if(((DMaps[currdmap].flags&dmfWHIRLWIND && TriforceCount()) || DMaps[currdmap].flags&dmfWHIRLWINDRET) &&
11088
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
46 itm.misc2 >= 0 && itm.misc2 <= 8 && !whistleflag)
11089
4/12
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 42 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 42 times.
✗ Branch 11 not taken.
84 Lwpns.add(new weapon((zfix)(where==left?zfix(240):where==right?zfix(0):x),
11090
3/10
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 42 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 42 times.
✗ Branch 9 not taken.
42 (zfix)(where==down?zfix(0):where==up?zfix(160):y),
11091
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 (zfix)0,
11092 wWind,
11093 0, //type
11094 0,
11095 42 where,
11096
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 itemid,getUID(),false,false,true,0)); //last arg is byte special, used to override type for wWind for now. -Z 18JULY2020
11097
11098 73 whistleitem=itemid;
11099 }
11100
11101 99 ret = false;
11102 }
11103 99 break;
11104
11105 case itype_bomb:
11106 {
11107 //Remote detonation
11108
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 459 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 463 times.
464 if(Lwpns.idCount(wLitBomb) >= zc_max(itm.misc2,1))
11109 {
11110 1 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
11111
11112
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 while(Lwpns.idCount(wLitBomb) && ew->misc == 0)
11113 {
11114 //If this ever needs a version check, in the future. -z
11115 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 ) )
11116 {
11117 if ( ew->power > 1 ) //Don't reduce 1 to 0. -Z
11118 ew->power *= 0.5; //Remote bombs were dealing double damage. -Z
11119 }
11120 ew->misc=50;
11121 ew->clk=ew->misc-3;
11122 ew->id=wBomb;
11123 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
11124 }
11125
11126 1 deselectbombs(false);
11127 1 return false;
11128 }
11129
11130
2/4
✓ Branch 0 taken 463 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 463 times.
463 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11131 {
11132 return item_error();
11133 }
11134
11135 463 paymagiccost(itemid);
11136
11137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 463 times.
463 if(itm.misc1>0) // If not remote bombs
11138 463 deselectbombs(false);
11139
11140
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 412 times.
463 if(isdungeon())
11141 {
11142
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 36 times.
412 wy=zc_max(wy,16);
11143 412 }
11144
11145
4/8
✓ Branch 0 taken 463 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 463 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 463 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 463 times.
✗ Branch 7 not taken.
926 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitBomb,itm.fam_type,
11146
2/4
✓ Branch 0 taken 463 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 463 times.
✗ Branch 3 not taken.
463 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11147 463 sfx(WAV_PLACE,pan(wx));
11148 }
11149 463 break;
11150
11151 case itype_sbomb:
11152 {
11153 //Remote detonation
11154
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(Lwpns.idCount(wLitSBomb) >= zc_max(itm.misc2,1))
11155 {
11156 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
11157
11158 while(Lwpns.idCount(wLitSBomb) && ew->misc == 0)
11159 {
11160 ew->misc=50;
11161 ew->clk=ew->misc-3;
11162 ew->id=wSBomb;
11163 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
11164 }
11165
11166 deselectbombs(true);
11167 return false;
11168 }
11169
11170
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11171 {
11172 return item_error();
11173 }
11174
11175 12 paymagiccost(itemid);
11176
11177
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(itm.misc1>0) // If not remote bombs
11178 12 deselectbombs(true);
11179
11180
6/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
12 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitSBomb,itm.fam_type,itm.power*game->get_hero_dmgmult(),dir, itemid,getUID(),false,false,true));
11181 12 sfx(WAV_PLACE,pan(wx));
11182 }
11183 12 break;
11184
11185 case itype_wand:
11186 {
11187
2/2
✓ Branch 0 taken 363 times.
✓ Branch 1 taken 835 times.
1198 if(Lwpns.idCount(wMagic))
11188 {
11189 363 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11190 363 return false;
11191 }
11192
11193 835 int32_t bookid = current_item_id(itype_book);
11194
3/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 437 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398 times.
835 bool paybook = (bookid>-1 && checkbunny(bookid) && checkmagiccost(bookid));
11195
11196
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 835 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
835 if(!(itm.flags&ITEM_FLAG1) && !paybook) //Can the wand shoot without the book?
11197 {
11198 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11199 return false;
11200 }
11201
11202
3/6
✓ Branch 0 taken 835 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 835 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 835 times.
✗ Branch 5 not taken.
835 if(!checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_WAND_COST || checkmagiccost(itemid)))
11203 {
11204 return item_error();
11205 }
11206
11207
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 3 times.
835 if(Lwpns.idCount(wBeam))
11208 3 Lwpns.del(Lwpns.idFirst(wBeam));
11209
11210 int32_t type, pow;
11211
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 663 times.
835 if ( get_bit(quest_rules,qr_BROKENBOOKCOST) )
11212 {
11213
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 74 times.
172 type = bookid != -1 ? current_item(itype_book) : itm.fam_type;
11214
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 74 times.
172 pow = (bookid != -1 ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
11215 172 }
11216 else
11217 {
11218
3/4
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 363 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 300 times.
663 type = (bookid != -1 && paybook) ? current_item(itype_book) : itm.fam_type;
11219
3/4
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 363 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 300 times.
663 pow = ((bookid != -1 && paybook) ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
11220 }
11221
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 835 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1670 times.
✓ Branch 4 taken 835 times.
✓ Branch 5 taken 835 times.
1670 for(int32_t i=(spins==1?up:dir); i<=(spins==1 ? right:dir); i++)
11222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 835 times.
1670 if(dir!=(i^1))
11223 {
11224
5/10
✓ Branch 0 taken 835 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 835 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 835 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 835 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 835 times.
✗ Branch 9 not taken.
835 weapon *magic = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wMagic,type,pow,i, itemid,getUID(),false,false,true);
11225
2/2
✓ Branch 0 taken 437 times.
✓ Branch 1 taken 398 times.
835 if(paybook)
11226 398 magic->linkedItem = bookid;
11227 //magic->dir = this->dir; //Save player dir for special weapons.
11228 835 Lwpns.add(magic);
11229 835 }
11230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 835 times.
835 if(!(misc_internal_hero_flags & LF_PAID_WAND_COST))
11231 835 paymagiccost(itemid);
11232 else misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11233
11234
2/2
✓ Branch 0 taken 437 times.
✓ Branch 1 taken 398 times.
835 if(paybook)
11235 398 paymagiccost(current_item_id(itype_book));
11236
11237
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 437 times.
835 if(bookid != -1)
11238 {
11239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (( itemsbuf[bookid].flags & ITEM_FLAG4 ))
11240 {
11241 sfx(itemsbuf[bookid].misc2,pan(wx));
11242 }
11243 else
11244 {
11245 398 sfx(itm.usesound,pan(wx));
11246 }
11247 398 }
11248 else
11249 437 sfx(itm.usesound,pan(wx));
11250 }
11251 /*
11252 // Fireball Wand
11253 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wRefFireball,0,2*game->get_hero_dmgmult(),dir));
11254 switch (dir)
11255 {
11256 case up:
11257 Lwpns.spr(Lwpns.Count()-1)->angle=-PI/2;
11258 Lwpns.spr(Lwpns.Count()-1)->dir=up;
11259 break;
11260 case down:
11261 Lwpns.spr(Lwpns.Count()-1)->angle=PI/2;
11262 Lwpns.spr(Lwpns.Count()-1)->dir=down;
11263 break;
11264 case left:
11265 Lwpns.spr(Lwpns.Count()-1)->angle=PI;
11266 Lwpns.spr(Lwpns.Count()-1)->dir=left;
11267 break;
11268 case right:
11269 Lwpns.spr(Lwpns.Count()-1)->angle=0;
11270 Lwpns.spr(Lwpns.Count()-1)->dir=right;
11271 break;
11272 }
11273 Lwpns.spr(Lwpns.Count()-1)->clk=16;
11274 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step=3.5;
11275 Lwpns.spr(Lwpns.Count()-1)->dummy_bool[0]=true; //homing
11276 */
11277 835 break;
11278
11279 case itype_sword:
11280 {
11281
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8777 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8777 if(!(checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_SWORD_COST || checkmagiccost(itemid))))
11282 {
11283 return item_error();
11284 }
11285
11286
4/4
✓ Branch 0 taken 1711 times.
✓ Branch 1 taken 7066 times.
✓ Branch 2 taken 1711 times.
✓ Branch 3 taken 7066 times.
8777 if((Lwpns.idCount(wBeam) && spins==0)||Lwpns.idCount(wMagic))
11287 {
11288 1711 misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
11289 1711 return false;
11290 }
11291
11292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7066 times.
7066 if(!(misc_internal_hero_flags & LF_PAID_SWORD_COST))//If already paid to use sword melee, don't charge again
11293 7066 paymagiccost(itemid);
11294 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
11295 float temppower;
11296
11297
1/2
✓ Branch 0 taken 7066 times.
✗ Branch 1 not taken.
7066 if(itm.flags & ITEM_FLAG2)
11298 {
11299 7066 temppower=game->get_hero_dmgmult()*itm.power;
11300 7066 temppower=temppower*itm.misc2;
11301 7066 temppower=temppower/100;
11302 7066 }
11303 else
11304 {
11305 temppower = game->get_hero_dmgmult()*itm.misc2;
11306 }
11307
11308 //Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID()));
11309 //Add weapon script to sword beams.
11310
5/10
✓ Branch 0 taken 7066 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7066 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7066 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7066 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7066 times.
✗ Branch 9 not taken.
7066 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID(),false,false,true));
11311 //weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //the pointer to this beam
11312 //w->weaponscript = itm.weaponscript;
11313 //w->canrunscript = 0;
11314 7066 sfx(WAV_BEAM,pan(wx));
11315 }
11316 7066 break;
11317
11318 case itype_candle:
11319 {
11320 896 int32_t countid = itemid;
11321
2/2
✓ Branch 0 taken 876 times.
✓ Branch 1 taken 20 times.
896 if(get_bit(quest_rules, qr_CANDLES_SHARED_LIMIT))
11322 876 countid = -itype_candle;
11323
5/6
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 101 times.
✓ Branch 2 taken 101 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 887 times.
896 if(itm.flags&ITEM_FLAG1 && usecounts[countid] >= zc_max(1, itm.misc3))
11324 {
11325 9 return false;
11326 }
11327
11328
3/4
✓ Branch 0 taken 887 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 824 times.
887 if(Lwpns.idCount(wFire) >= (itm.misc3 < 1 ? 2 : itm.misc3))
11329 {
11330 63 return false;
11331 }
11332
11333
2/4
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 824 times.
824 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11334 {
11335 return item_error();
11336 }
11337
11338 824 paymagiccost(itemid);
11339
11340
2/2
✓ Branch 0 taken 732 times.
✓ Branch 1 taken 92 times.
824 if(itm.flags&ITEM_FLAG1) ++usecounts[countid];
11341
11342
4/8
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 824 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 824 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 824 times.
✗ Branch 7 not taken.
1648 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wFire,
11343 //(itm.fam_type > 1), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
11344 824 (itm.fam_type), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
11345
2/4
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 824 times.
✗ Branch 3 not taken.
824 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11346 824 sfx(itm.usesound,pan(wx));
11347 824 attack=wFire;
11348 }
11349 824 break;
11350
11351 case itype_script1: case itype_script2: case itype_script3: case itype_script4: case itype_script5:
11352 case itype_script6: case itype_script7: case itype_script8: case itype_script9: case itype_script10:
11353 {
11354 int32_t wtype = wScript1 + (itm.family-itype_script1);
11355 if(Lwpns.idCount(wtype))
11356 return false;
11357
11358 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11359 {
11360 return item_error();
11361 }
11362
11363 if(!get_bit(quest_rules, qr_CUSTOMWEAPON_IGNORE_COST))
11364 paymagiccost(itemid);
11365
11366 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wtype,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11367 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = itm.misc1/100;
11368 sfx(itm.usesound,pan(wx));
11369 }
11370 break;
11371
11372 case itype_icerod:
11373 {
11374 if(Lwpns.idCount(wIce))
11375 return false;
11376
11377 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11378 {
11379 return item_error();
11380 }
11381
11382 if(!get_bit(quest_rules, qr_CUSTOMWEAPON_IGNORE_COST))
11383 paymagiccost(itemid);
11384
11385 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wIce,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11386 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = itm.misc1/100;
11387 sfx(itm.usesound,pan(wx));
11388 }
11389 break;
11390
11391 case itype_arrow:
11392 {
11393
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 361 times.
378 if(Lwpns.idCount(wArrow) > itm.misc2)
11394 17 return false;
11395
11396
2/4
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 361 times.
361 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11397 {
11398 return item_error();
11399 }
11400
11401 361 paymagiccost(itemid);
11402
11403
6/12
✓ Branch 0 taken 361 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 361 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 361 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 361 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 361 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 361 times.
✗ Branch 11 not taken.
361 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wArrow,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11404 361 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step*=(current_item_power(itype_bow)+1)/2;
11405 361 sfx(itm.usesound,pan(wx));
11406 }
11407 361 break;
11408
11409 case itype_bait:
11410 {
11411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(Lwpns.idCount(wBait)) //TODO: More than one Bait per screen?
11412 return false;
11413
11414
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!checkbunny(itemid))
11415 return item_error();
11416
11417
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
12 bool grumble = (tmpscr->room==rGRUMBLE && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)));
11418
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 bool checkcost = grumble || !(itm.flags & ITEM_FLAG4);
11419
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 bool paycost = grumble || !(itm.flags & (ITEM_FLAG4|ITEM_FLAG5));
11420
11421
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(!grumble && (itm.flags & ITEM_FLAG2))
11422 return item_error(); //Only usable for grumble rooms
11423
11424
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(checkcost && !checkmagiccost(itemid))
11425 return item_error();
11426
11427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(paycost)
11428 6 paymagiccost(itemid);
11429 6 sfx(itm.usesound,pan(wx));
11430
11431
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(grumble)
11432 {
11433
4/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
6 items.add(new item((zfix)wx,(zfix)wy,(zfix)0,itemid,ipDUMMY+ipFADE,0));
11434 6 fadeclk=66;
11435 6 dismissmsg();
11436 6 clear_bitmap(pricesdisplaybuf);
11437 6 set_clip_state(pricesdisplaybuf, 1);
11438 // putscr(scrollbuf,0,0,tmpscr);
11439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
11440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(!(itm.flags & ITEM_FLAG3)) //"Don't remove when feeding" flag
11441 {
11442 6 removeItemsOfFamily(game,itemsbuf,itype_bait);
11443 6 verifyBothWeapons();
11444 6 }
11445 6 sfx(tmpscr->secretsfx);
11446 6 return false;
11447 }
11448
11449 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBait,0,0,dir,itemid,getUID(),false,false,true));
11450 break;
11451 }
11452
11453 case itype_brang:
11454 {
11455
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 5123 times.
5343 if(Lwpns.idCount(wBrang) > itm.misc2)
11456 220 return false;
11457
11458
2/4
✓ Branch 0 taken 5123 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5123 times.
5123 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11459 {
11460 return item_error();
11461 }
11462
11463 5123 paymagiccost(itemid);
11464 5123 current_item_power(itype_brang);
11465
6/12
✓ Branch 0 taken 5123 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5123 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5123 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5123 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5123 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5123 times.
✗ Branch 11 not taken.
5123 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBrang,itm.fam_type,(itm.power*game->get_hero_dmgmult()),dir,itemid,getUID(),false,false,true));
11466 }
11467 5123 break;
11468
11469 case itype_hookshot:
11470 case itype_switchhook:
11471 {
11472
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(inlikelike || Lwpns.idCount(wHookshot))
11473 return false;
11474
11475
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11476 {
11477 return item_error();
11478 }
11479 33 bool sw = itm.family == itype_switchhook;
11480
11481
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
33 if(sw && (itm.flags&ITEM_FLAG8))
11482 switchhook_cost_item = itemid;
11483 33 else paymagiccost(itemid);
11484
11485 33 bool use_hookshot=true;
11486 33 bool hit_hs = false, hit_solid = false, insta_switch = false;
11487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
11488 33 int32_t cpos = -1, ffcpos = -1;
11489
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 33 times.
66 for(int32_t i=0; i<=max_layer && !hit_hs; ++i)
11490 {
11491
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 13 times.
33 if(dir==up)
11492 {
11493
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(check_hshot(i,x+2,y-7,sw, &cpos, &ffcpos))
11494 hit_hs = true;
11495 13 }
11496
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
20 else if(dir==down)
11497 {
11498
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(check_hshot(i,x+12,y+23,sw, &cpos, &ffcpos))
11499 hit_hs = true;
11500 4 }
11501
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 13 times.
16 else if(dir==left)
11502 {
11503
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(check_hshot(i,x-7,y+12,sw, &cpos, &ffcpos))
11504 hit_hs = true;
11505 3 }
11506
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 else if(dir==right)
11507 {
11508
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(check_hshot(i,x+23,y+12,sw, &cpos, &ffcpos))
11509 hit_hs = true;
11510 13 }
11511 //Diagonal Hookshot (6)
11512 else if(dir==r_down)
11513 {
11514 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
11515 hit_hs = true;
11516 }
11517 else if(dir==l_down)
11518 {
11519 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
11520 hit_hs = true;
11521 }
11522 else if(dir==r_up)
11523 {
11524 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
11525 hit_hs = true;
11526 }
11527 else if(dir==l_up)
11528 {
11529 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
11530 hit_hs = true;
11531 }
11532 33 }
11533
7/10
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 13 times.
✓ Branch 6 taken 11 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 33 times.
✗ Branch 9 not taken.
33 if(dir==up && _walkflag(x+2,y+4,1,SWITCHBLOCK_STATE) && !ishookshottable(x.getInt(),int32_t(y+4)))
11534 hit_solid = true;
11535
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(hit_hs)
11536 {
11537 if(sw)
11538 insta_switch = true; //switch immediately
11539 else use_hookshot = false; //No hooking against grabbable
11540 }
11541
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
33 if(hit_solid && !insta_switch)
11542 use_hookshot = false;
11543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(use_hookshot)
11544 {
11545 33 int32_t hookitem = itm.fam_type;
11546 33 int32_t hookpower = itm.power;
11547 33 byte allow_diagonal = (itm.flags & ITEM_FLAG2) ? 1 : 0;
11548
11549
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!Lwpns.has_space())
11550 {
11551 Lwpns.del(0);
11552 }
11553
11554
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!Lwpns.has_space(2))
11555 {
11556 Lwpns.del(0);
11557 }
11558
11559
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
33 switch(dir)
11560 {
11561 case up:
11562 {
11563 13 hookshot_used=true;
11564 13 hs_switcher = sw;
11565
4/8
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13 times.
✗ Branch 7 not taken.
26 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11566
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11567 13 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11568
5/10
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 13 times.
✗ Branch 9 not taken.
26 Lwpns.add(new weapon((zfix)wx,(zfix)wy-4,(zfix)wz,wHookshot,hookitem,
11569
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11570 13 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11571 13 hs_startx=wx;
11572 13 hs_starty=wy-4;
11573 }
11574 13 break;
11575
11576 case down:
11577 {
11578 4 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11579 4 hookshot_used=true;
11580 4 hs_switcher = sw;
11581
5/10
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
8 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11582
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11583 4 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11584
5/10
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
8 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11585
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11586 4 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11587 4 hs_startx=wx;
11588 4 hs_starty=wy;
11589 }
11590 4 break;
11591
11592 case left:
11593 {
11594 3 hookshot_used=true;
11595 3 hs_switcher = sw;
11596
4/8
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
6 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11597
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11598 3 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11599
4/8
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
6 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11600
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11601 3 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11602 3 hs_startx=wx-4;
11603 3 hs_starty=wy;
11604 }
11605 3 break;
11606
11607 case right:
11608 {
11609 13 hookshot_used=true;
11610 13 hs_switcher = sw;
11611
4/8
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13 times.
✗ Branch 7 not taken.
26 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11612
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11613 13 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11614
4/8
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13 times.
✗ Branch 7 not taken.
26 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11615
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11616 13 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11617 13 hs_startx=wx+4;
11618 13 hs_starty=wy;
11619 }
11620 13 break;
11621 //Diagonal Hookshot (7)
11622 case r_down:
11623 {
11624 hookshot_used=true;
11625 hs_switcher = sw;
11626 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11627 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11628 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11629 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11630 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11631 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11632 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11633 hs_startx=wx+4;
11634 hs_starty=wy;
11635 }
11636 break;
11637
11638 case r_up:
11639 {
11640 hookshot_used=true;
11641 hs_switcher = sw;
11642 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11643 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11644 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11645 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11646 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11647 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11648 hs_startx=wx+4;
11649 hs_starty=wy;
11650 }
11651 break;
11652
11653 case l_down:
11654 {
11655 hookshot_used=true;
11656 hs_switcher = sw;
11657 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11658 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11659 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11660 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11661 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11662 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11663 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11664 hs_startx=wx+4;
11665 hs_starty=wy;
11666 }
11667 break;
11668
11669 case l_up:
11670 {
11671 hookshot_used=true;
11672 hs_switcher = sw;
11673 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11674 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11675 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11676 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11677 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11678 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11679 hs_startx=wx+4;
11680 hs_starty=wy;
11681 }
11682 break;
11683 }
11684 33 hookshot_frozen=true;
11685 33 }
11686
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(insta_switch)
11687 {
11688 weapon* w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot));
11689 if (cpos > -1) hooked_combopos = cpos;
11690 if (ffcpos > -1)
11691 {
11692 switching_object = &(tmpscr->ffcs[ffcpos]);
11693 switching_object->switch_hooked = true;
11694 }
11695 w->misc=2;
11696 w->step=0;
11697 doSwitchHook(itm.misc5);
11698 if(itm.usesound2)
11699 sfx(itm.usesound2,pan(int32_t(x)));
11700 else if(QMisc.miscsfx[sfxSWITCHED])
11701 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
11702 stop_sfx(itm.usesound);
11703 }
11704 }
11705 33 break;
11706
11707 case itype_dinsfire:
11708 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11709 return false;
11710
11711 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11712 {
11713 return item_error();
11714 }
11715
11716 paymagiccost(itemid);
11717 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11718 else {action=casting; FFCore.setHeroAction(casting);}
11719 magicitem=itemid;
11720 break;
11721
11722 case itype_faroreswind:
11723 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11724 return false;
11725
11726 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11727 {
11728 return item_error();
11729 }
11730
11731 paymagiccost(itemid);
11732 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11733 else {action=casting; FFCore.setHeroAction(casting);}
11734 magicitem=itemid;
11735 break;
11736
11737 case itype_nayruslove:
11738 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11739 return false;
11740
11741 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11742 {
11743 return item_error();
11744 }
11745
11746 paymagiccost(itemid);
11747 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11748 else {action=casting; FFCore.setHeroAction(casting);}
11749 magicitem=itemid;
11750 break;
11751
11752 case itype_cbyrna:
11753 {
11754 //Beams already deployed
11755 if(Lwpns.idCount(wCByrna))
11756 {
11757 stopCaneOfByrna();
11758 return false;
11759 }
11760
11761 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11762 {
11763 stop_sfx(itm.usesound); //if we can't pay the cost, kill the sound.
11764 //last_cane_of_byrna_item_id = -1; //no, we'd do this in a byrna cleanup function.
11765 return false;
11766 }
11767
11768 paymagiccost(itemid);
11769 last_cane_of_byrna_item_id = itemid;
11770 //zprint("itm.misc3: %d\n", itm.misc3);
11771 for(int32_t i=0; i<itm.misc3; i++)
11772 {
11773 //byrna weapons are added here
11774 //space them apart
11775 //zprint("Added byrna weapon %d.\n", i);
11776 //the iterator isn passed to 'type'. weapons.cpp converts thisd to
11777 //'quantity_iterator' pn construction; and this is used for orbit initial spacing.
11778 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11779 //Lwpns.add(new weapon((zfix)wx+cos(2 * PI / (i+1)),(zfix)wy+sin(2 * PI / (i+1)),(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11780 //wx += cos(2 * PI / (itm.misc3-i));
11781 //wy += sin(2 * PI / (itm.misc3-i));
11782 }
11783 if(!(Lwpns.idCount(wCByrna)))
11784 stop_sfx(itm.usesound); //If we can't create the beams, kill the sound.
11785 }
11786 break;
11787
11788 case itype_clock:
11789 {
11790 ret = false;
11791 if(!(itm.flags & ITEM_FLAG1))
11792 break; //Passive clock, don't use
11793 if((itm.flags & ITEM_FLAG2) && watch) //"Can't activate while clock active"
11794 break;
11795 if(!(checkbunny(itemid) && checkmagiccost(itemid))) //cost/bunny check
11796 {
11797 return item_error();
11798 }
11799
11800 paymagiccost(itemid);
11801
11802 setClock(watch=true);
11803
11804 for(int32_t i=0; i<eMAXGUYS; i++)
11805 clock_zoras[i]=0;
11806
11807 clockclk=itm.misc1;
11808 sfx(itm.usesound);
11809 break;
11810 }
11811 case itype_killem:
11812 {
11813 ret = false;
11814 if(!(itm.flags & ITEM_FLAG1))
11815 break; //Passive killemall, don't use
11816
11817 if(!(checkbunny(itemid) && checkmagiccost(itemid))
11818 || !can_kill_em_all()) //No enemies onscreen
11819 {
11820 return item_error();
11821 }
11822
11823 paymagiccost(itemid);
11824
11825 kill_em_all();
11826 sfx(itm.usesound);
11827 break;
11828 }
11829 case itype_refill:
11830 {
11831 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11832 {
11833 return item_error();
11834 }
11835
11836 bool did_something = false;
11837
11838 if(itm.flags & ITEM_FLAG1) //Cure sword jinx
11839 {
11840 if(swordclk)
11841 did_something = true;
11842 swordclk = 0;
11843 verifyAWpn();
11844 }
11845 for(auto q = 0; q < 5; ++q)
11846 {
11847 auto ctr = itm.misc(q);
11848 if(unsigned(ctr) >= MAX_COUNTERS)
11849 continue;
11850 int16_t amnt = vbound(itm.misc(q+5),-32768,32767);
11851 if(!amnt) continue;
11852 bool gradual = itm.flags & ITEM_FLAG2;
11853 if(amnt > 0)
11854 {
11855 if(game->get_counter(ctr) + game->get_dcounter(ctr) >= game->get_maxcounter(ctr))
11856 {
11857 //Can't *do* anything... skip
11858 continue;
11859 }
11860 if(game->get_counter(ctr) >= game->get_maxcounter(ctr))
11861 {
11862 //Can't do anything unless affecting dcounter
11863 gradual = true;
11864 }
11865 }
11866 else //Negative
11867 {
11868 if(game->get_counter(ctr) + game->get_dcounter(ctr) <= 0)
11869 {
11870 //Can't *do* anything... skip
11871 continue;
11872 }
11873 if(game->get_counter(ctr) <= 0)
11874 {
11875 //Can't do anything unless affecting dcounter
11876 gradual = true;
11877 }
11878 }
11879 did_something = true;
11880 if(gradual) //Gradual
11881 {
11882 game->change_dcounter(amnt, ctr);
11883 }
11884 else
11885 {
11886 game->change_counter(amnt, ctr);
11887 }
11888 }
11889 if(!did_something)
11890 {
11891 return item_error();
11892 }
11893 paymagiccost(itemid);
11894 sfx(itm.usesound);
11895 ret = false;
11896 break;
11897 }
11898
11899 default:
11900 174 ret = false;
11901 174 }
11902
11903
2/2
✓ Branch 0 taken 15054 times.
✓ Branch 1 taken 20 times.
15074 if(itm.flags & ITEM_DOWNGRADE)
11904 {
11905 20 game->set_item(itemid,false);
11906
11907 // Maybe Item Override has allowed the same item in both slots?
11908
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(Bwpn == itemid)
11909 {
11910 Bwpn = 0;
11911 game->forced_bwpn = -1;
11912 verifyBWpn();
11913 }
11914
11915
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(Awpn == itemid)
11916 {
11917 Awpn = 0;
11918 game->forced_awpn = -1;
11919 verifyAWpn();
11920 }
11921
11922
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(Xwpn == itemid)
11923 {
11924 Xwpn = 0;
11925 game->forced_xwpn = -1;
11926 verifyXWpn();
11927 }
11928
11929
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(Ywpn == itemid)
11930 {
11931 Ywpn = 0;
11932 game->forced_ywpn = -1;
11933 verifyYWpn();
11934 }
11935 20 }
11936
11937 15074 return ret;
11938 17517 }
11939
11940
11941 574696 bool HeroClass::doattack()
11942 {
11943 //int32_t s = BSZ ? 0 : 11;
11944 574696 int32_t s = (zinit.heroAnimationStyle==las_bszelda) ? 0 : 11;
11945
11946
3/4
✓ Branch 0 taken 12831 times.
✓ Branch 1 taken 561865 times.
✓ Branch 2 taken 12831 times.
✗ Branch 3 not taken.
574696 int32_t bugnetid = (directWpn>-1 && itemsbuf[directWpn].family==itype_bugnet) ? directWpn : current_item_id(itype_bugnet);
11947
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 574696 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
574696 if(attack==wBugNet && bugnetid!=-1)
11948 {
11949 if(++attackclk >= NET_CLK_TOTAL)
11950 return false;
11951
11952 return true;
11953 }
11954
11955 // Abort attack if attackclk has run out and:
11956 // * the attack is not Hammer, Sword with Spin Scroll, Candle, or Wand, OR
11957 // * you aren't holding down the A button, you're not charging, and/or you're still spinning
11958
11959
6/6
✓ Branch 0 taken 35792 times.
✓ Branch 1 taken 538904 times.
✓ Branch 2 taken 34364 times.
✓ Branch 3 taken 1428 times.
✓ Branch 4 taken 2287 times.
✓ Branch 5 taken 3091 times.
580074 if(attackclk>=(spins>0?8:14) && attack!=wHammer &&
11960
12/12
✓ Branch 0 taken 28820 times.
✓ Branch 1 taken 5544 times.
✓ Branch 2 taken 3567 times.
✓ Branch 3 taken 25253 times.
✓ Branch 4 taken 29601 times.
✓ Branch 5 taken 4763 times.
✓ Branch 6 taken 28986 times.
✓ Branch 7 taken 615 times.
✓ Branch 8 taken 3566 times.
✓ Branch 9 taken 1812 times.
✓ Branch 10 taken 2264 times.
✓ Branch 11 taken 1302 times.
34364 (((attack!=wSword || !current_item(itype_spinscroll) || inlikelike) && attack!=wWand && attack!=wFire && attack!=wCByrna) || !((attack==wSword && isWpnPressed(itype_sword) && spins==0) || charging>0)))
11961 {
11962 32077 tapping=false;
11963 32077 return false;
11964 }
11965
11966
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 542526 times.
542619 if(attackclk>29)
11967 {
11968 93 tapping=false;
11969 93 return false;
11970 }
11971
11972
4/4
✓ Branch 0 taken 12039 times.
✓ Branch 1 taken 530487 times.
✓ Branch 2 taken 10239 times.
✓ Branch 3 taken 1800 times.
542526 int32_t candleid = (directWpn>-1 && itemsbuf[directWpn].family==itype_candle) ? directWpn : current_item_id(itype_candle);
11973
3/4
✓ Branch 0 taken 12039 times.
✓ Branch 1 taken 530487 times.
✓ Branch 2 taken 12039 times.
✗ Branch 3 not taken.
542526 int32_t byrnaid = (directWpn>-1 && itemsbuf[directWpn].family==itype_cbyrna) ? directWpn : current_item_id(itype_cbyrna);
11974 // An attack can be "walked out-of" after 8 frames, unless it's:
11975 // * a sword stab
11976 // * a hammer pound
11977 // * a wand thrust
11978 // * a candle thrust
11979 // * a cane thrust
11980 // In which case it should continue.
11981
8/8
✓ Branch 0 taken 24695 times.
✓ Branch 1 taken 517831 times.
✓ Branch 2 taken 63087 times.
✓ Branch 3 taken 38392 times.
✓ Branch 4 taken 489483 times.
✓ Branch 5 taken 66740 times.
✓ Branch 6 taken 102463 times.
✓ Branch 7 taken 387020 times.
642450 if((attack==wCatching && attackclk>4)||(attack!=wWand && attack!=wSword && attack!=wHammer
11982
5/6
✓ Branch 0 taken 99924 times.
✓ Branch 1 taken 2539 times.
✓ Branch 2 taken 10812 times.
✓ Branch 3 taken 89112 times.
✓ Branch 4 taken 10812 times.
✗ Branch 5 not taken.
102463 && (attack!=wFire || (candleid!=-1 && !(itemsbuf[candleid].wpn)))
11983
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 89112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99924 && (attack!=wCByrna || (byrnaid!=-1 && !(itemsbuf[byrnaid].wpn)))
11984
2/2
✓ Branch 0 taken 99924 times.
✓ Branch 1 taken 10812 times.
89112 && (attack != wBugNet) && attackclk>7))
11985 {
11986
8/8
✓ Branch 0 taken 35349 times.
✓ Branch 1 taken 1488 times.
✓ Branch 2 taken 34155 times.
✓ Branch 3 taken 1194 times.
✓ Branch 4 taken 32540 times.
✓ Branch 5 taken 1615 times.
✓ Branch 6 taken 1497 times.
✓ Branch 7 taken 31043 times.
163011 if(DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight())
11987 {
11988 5794 lstep = s;
11989 5794 return false;
11990 }
11991 31043 }
11992
11993
2/2
✓ Branch 0 taken 1916 times.
✓ Branch 1 taken 507050 times.
508966 if(charging==0)
11994 {
11995 507050 lstep=0;
11996 507050 }
11997
11998 // Work out the sword charge-up delay
11999 508966 int32_t magiccharge = 192, normalcharge = 64;
12000 508966 int32_t itemid = current_item_id(itype_chargering);
12001
12002
2/2
✓ Branch 0 taken 470656 times.
✓ Branch 1 taken 38310 times.
508966 if(itemid>=0)
12003 {
12004 38310 normalcharge = itemsbuf[itemid].misc1;
12005 38310 magiccharge = itemsbuf[itemid].misc2;
12006 38310 }
12007
12008 508966 itemid = current_item_id(attack==wHammer ? itype_quakescroll : itype_spinscroll);
12009
12010 508966 bool doCharge=true;
12011
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 508966 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
508966 if(z!=0 && fakez != 0)
12012 doCharge=false;
12013
2/2
✓ Branch 0 taken 387020 times.
✓ Branch 1 taken 121946 times.
508966 if(attack==wSword)
12014 {
12015
4/4
✓ Branch 0 taken 1661 times.
✓ Branch 1 taken 385359 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 1637 times.
387020 if(!(attackclk==SWORDCHARGEFRAME && isWpnPressed(itype_sword)))
12016 385383 doCharge=false;
12017
2/2
✓ Branch 0 taken 417 times.
✓ Branch 1 taken 1220 times.
1637 else if(charging<=normalcharge)
12018 {
12019
3/6
✓ Branch 0 taken 1220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1220 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1220 times.
✗ Branch 5 not taken.
1220 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
12020 doCharge=false;
12021 1220 }
12022 387020 }
12023
2/2
✓ Branch 0 taken 2539 times.
✓ Branch 1 taken 119407 times.
121946 else if(attack==wHammer)
12024 {
12025
4/4
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 2447 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 8 times.
2539 if(!(attackclk==HAMMERCHARGEFRAME && isWpnPressed(itype_hammer)))
12026 2531 doCharge=false;
12027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 else if(charging<=normalcharge)
12028 {
12029
3/6
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
8 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
12030 doCharge=false;
12031 8 }
12032 2539 }
12033 else
12034 119407 doCharge=false;
12035
12036 // Now work out the magic cost
12037 508966 itemid = current_item_id(attack==wHammer ? itype_quakescroll : itype_spinscroll);
12038
12039 // charging up weapon...
12040 //
12041
2/2
✓ Branch 0 taken 1645 times.
✓ Branch 1 taken 507321 times.
508966 if(doCharge)
12042 {
12043 // Increase charging while holding down button.
12044
3/4
✓ Branch 0 taken 1645 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 1517 times.
1645 if(spins==0 && charging<magiccharge)
12045 1517 charging++;
12046
12047 // Once a charging threshold is reached, play the sound.
12048
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1636 times.
1645 if(charging==normalcharge)
12049 {
12050 9 paymagiccost(itemid); //!DIMITODO: Can this underflow or even just do it even if you don't have magic?
12051 9 sfx(WAV_ZN1CHARGE,pan(x.getInt()));
12052 9 }
12053
2/2
✓ Branch 0 taken 1633 times.
✓ Branch 1 taken 3 times.
1636 else if(charging==magiccharge)
12054 {
12055 3 itemid = current_item_id(attack==wHammer ? itype_quakescroll2 : itype_spinscroll2);
12056
12057
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if(itemid>-1 && checkbunny(itemid) && checkmagiccost(itemid))
12058 {
12059 3 paymagiccost(itemid);
12060 3 charging++; // charging>magiccharge signifies a successful supercharge.
12061 3 sfx(WAV_ZN1CHARGE2,pan(x.getInt()));
12062 3 }
12063 3 }
12064 1645 }
12065
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 507321 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
507321 else if(attack==wCByrna && byrnaid!=-1)
12066 {
12067 if(!(itemsbuf[byrnaid].wpn))
12068 {
12069 attack = wNone;
12070 return startwpn(attackid); // Beam if the Byrna stab animation WASN'T used.
12071 }
12072
12073 bool beamcount = false;
12074
12075 for(int32_t i=0; i<Lwpns.Count(); i++)
12076 {
12077 weapon *w = ((weapon*)Lwpns.spr(i));
12078
12079 if(w->id==wCByrna)
12080 {
12081 beamcount = true;
12082 break;
12083 }
12084 }
12085
12086 // If beams already deployed, remove them
12087 if(!attackclk && beamcount)
12088 {
12089 return startwpn(attackid); // Remove beams instantly
12090 }
12091
12092 // Otherwise, continue
12093 ++attackclk;
12094 }
12095 else
12096 {
12097 507321 ++attackclk;
12098
12099
6/6
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 507165 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 131 times.
✓ Branch 4 taken 11 times.
✓ Branch 5 taken 14 times.
507321 if(attackclk==SWORDCHARGEFRAME && charging>0 && !tapping) //Signifies a tapped enemy
12100 {
12101 14 ++attackclk; // Won't continue charging
12102 14 charging=0;
12103 14 }
12104
12105 // Faster if spinning.
12106
2/2
✓ Branch 0 taken 506729 times.
✓ Branch 1 taken 592 times.
507321 if(spins>0)
12107 592 ++attackclk;
12108
12109 // Even faster if hurricane spinning.
12110
2/2
✓ Branch 0 taken 506889 times.
✓ Branch 1 taken 432 times.
507321 if(spins>5)
12111 432 attackclk+=2;
12112
12113 // If at a charging threshold, do a charged attack.
12114
5/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 507207 times.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 106 times.
✓ Branch 5 taken 8 times.
507321 if(charging>=normalcharge && (attack!=wSword || attackclk>=SWORDCHARGEFRAME) && !tapping)
12115 {
12116
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(attack==wSword)
12117 {
12118
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5 times.
8 spins=(charging>magiccharge ? (itemsbuf[current_item_id(itype_spinscroll2)].misc1*4)-3
12119 5 : (itemsbuf[current_item_id(itype_spinscroll)].misc1*4)+1);
12120 8 attackclk=1;
12121 8 sfx(itemsbuf[current_item_id(spins>5 ? itype_spinscroll2 : itype_spinscroll)].usesound,pan(x.getInt()));
12122 8 }
12123 /*
12124 else if(attack==wWand)
12125 {
12126 //Not reachable.. yet
12127 spins=1;
12128 }
12129 */
12130 else if(attack==wHammer && sideviewhammerpound())
12131 {
12132 spins=1; //signifies the quake hammer
12133 bool super = (charging>magiccharge && current_item(itype_quakescroll2));
12134 sfx(itemsbuf[current_item_id(super ? itype_quakescroll2 : itype_quakescroll)].usesound,pan(x.getInt()));
12135 quakeclk=(itemsbuf[current_item_id(super ? itype_quakescroll2 : itype_quakescroll)].misc1);
12136
12137 // general area stun
12138 for(int32_t i=0; i<GuyCount(); i++)
12139 {
12140 if(!isflier(GuyID(i)))
12141 {
12142 StunGuy(i,(itemsbuf[current_item_id(super ? itype_quakescroll2 : itype_quakescroll)].misc2)-
12143 distance(x,y,GuyX(i),GuyY(i)));
12144 }
12145 }
12146 }
12147 8 }
12148
6/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 507198 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 48 times.
507313 else if(tapping && attackclk<SWORDCHARGEFRAME && charging<magiccharge)
12149 48 charging++;
12150
12151
7/8
✓ Branch 0 taken 10603 times.
✓ Branch 1 taken 496718 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 496718 times.
✓ Branch 4 taken 16782 times.
✓ Branch 5 taken 479936 times.
✓ Branch 6 taken 349983 times.
✓ Branch 7 taken 157338 times.
507321 if(!isWpnPressed(attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword))
12152 157338 charging=0;
12153
12154
2/2
✓ Branch 0 taken 506203 times.
✓ Branch 1 taken 1118 times.
507321 if(attackclk>=SWORDCHARGEFRAME)
12155 1118 tapping = false;
12156 }
12157
12158
6/8
✓ Branch 0 taken 39994 times.
✓ Branch 1 taken 468972 times.
✓ Branch 2 taken 904 times.
✓ Branch 3 taken 39090 times.
✓ Branch 4 taken 904 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 904 times.
508966 if(attackclk==1 && attack==wFire && candleid!=-1 && !(itemsbuf[candleid].wpn))
12159 {
12160 904 return startwpn(attackid); // Flame if the Candle stab animation WASN'T used.
12161 }
12162
12163 508062 int32_t crossid = current_item_id(itype_crossscroll); //has Cross Beams scroll
12164
12165
10/12
✓ Branch 0 taken 475600 times.
✓ Branch 1 taken 32462 times.
✓ Branch 2 taken 36561 times.
✓ Branch 3 taken 439039 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 36529 times.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 20 times.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
508062 if(attackclk==13 || (attackclk==7 && spins>1 && crossid >=0 && checkbunny(crossid) && checkmagiccost(crossid)))
12166 {
12167
12168
4/4
✓ Branch 0 taken 799 times.
✓ Branch 1 taken 31675 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 223 times.
32474 int32_t wpnid = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? directWpn : current_item_id(itype_sword);
12169
2/2
✓ Branch 0 taken 32456 times.
✓ Branch 1 taken 18 times.
32474 int64_t templife = wpnid>=0? itemsbuf[wpnid].misc1 : 0;
12170
12171
4/4
✓ Branch 0 taken 32456 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 1568 times.
✓ Branch 3 taken 30888 times.
32474 if(wpnid>=0 && itemsbuf[wpnid].flags & ITEM_FLAG1)
12172 {
12173 30888 templife=templife*game->get_maxlife();
12174 30888 templife=templife/100;
12175 30888 }
12176 else
12177 {
12178 1586 templife*=game->get_hp_per_heart();
12179 }
12180
12181
2/2
✓ Branch 0 taken 17178 times.
✓ Branch 1 taken 15296 times.
32474 bool normalbeam = (int64_t(game->get_life())+(get_bit(quest_rules,qr_QUARTERHEART)?((game->get_hp_per_heart()/4)-1):((game->get_hp_per_heart()/2)-1))>=templife);
12182 32474 int32_t perilid = current_item_id(itype_perilscroll);
12183
3/4
✓ Branch 0 taken 1592 times.
✓ Branch 1 taken 30882 times.
✓ Branch 2 taken 1592 times.
✗ Branch 3 not taken.
32475 bool perilbeam = (perilid>=0 && wpnid>=0 && game->get_life()<=itemsbuf[perilid].misc1*game->get_hp_per_heart()
12184
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1591 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1592 && checkbunny(perilid) && checkmagiccost(perilid)
12185 // Must actually be able to shoot sword beams
12186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 && ((itemsbuf[wpnid].flags & ITEM_FLAG1)
12187
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 || itemsbuf[wpnid].misc1 <= game->get_maxlife()/game->get_hp_per_heart()));
12188
12189
4/4
✓ Branch 0 taken 26654 times.
✓ Branch 1 taken 5820 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 26635 times.
32474 if(attack==wSword && !tapping)
12190 {
12191
4/4
✓ Branch 0 taken 26634 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 8789 times.
✓ Branch 3 taken 17845 times.
26635 if(perilbeam || normalbeam)
12192 {
12193
1/2
✓ Branch 0 taken 8790 times.
✗ Branch 1 not taken.
8790 if(attackclk==7)
12194 paymagiccost(crossid); // Pay the Cross Beams magic cost.
12195
12196
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8789 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
8790 if(perilbeam && !normalbeam)
12197 1 paymagiccost(perilid); // Pay the Peril Beam magic cost.
12198
12199 // TODO: Something that would be cheap but disgraceful to hack in at this point is
12200 // a way to make the peril/cross beam item's power stat influence the strength
12201 // of the peril/cross beam...
12202 8790 startwpn(attackid);
12203 8790 }
12204 17845 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
12205 26635 }
12206
12207
2/2
✓ Branch 0 taken 31276 times.
✓ Branch 1 taken 1198 times.
32474 if(attack==wWand)
12208 1198 startwpn(attackid); // Flame if the Wand stab animation WAS used (it always is).
12209
12210
4/6
✓ Branch 0 taken 637 times.
✓ Branch 1 taken 31837 times.
✓ Branch 2 taken 637 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 637 times.
✗ Branch 5 not taken.
32474 if(attack==wFire && candleid!=-1 && itemsbuf[candleid].wpn) // Flame if the Candle stab animation WAS used.
12211 startwpn(attackid);
12212
12213
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 32474 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
32474 if(attack==wCByrna && byrnaid!=-1 && itemsbuf[byrnaid].wpn) // Beam if the Byrna stab animation WAS used.
12214 startwpn(attackid);
12215 32474 }
12216
12217
2/2
✓ Branch 0 taken 475974 times.
✓ Branch 1 taken 32088 times.
508062 if(attackclk==14)
12218 32088 lstep = s;
12219
12220 508062 return true;
12221 546930 }
12222
12223 6516154 bool HeroClass::can_attack()
12224 {
12225
4/4
✓ Branch 0 taken 6354656 times.
✓ Branch 1 taken 161498 times.
✓ Branch 2 taken 4392606 times.
✓ Branch 3 taken 1962050 times.
6516154 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
12226
4/6
✓ Branch 0 taken 6516154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6474096 times.
✓ Branch 3 taken 42058 times.
✓ Branch 4 taken 6474096 times.
✗ Branch 5 not taken.
7009072 if(action==hopping || action==swimming || action==freeze || action==sideswimfreeze
12227
5/8
✓ Branch 0 taken 6474096 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6474096 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6474096 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6472400 times.
✓ Branch 7 taken 1696 times.
6474096 || lstunclock > 0 || is_conveyor_stunned || spins>0 || usingActiveShield()
12228
3/4
✓ Branch 0 taken 6472400 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5428464 times.
✓ Branch 3 taken 1043936 times.
6472400 || ((action==attacking||action==sideswimattacking)
12229
2/2
✓ Branch 0 taken 246466 times.
✓ Branch 1 taken 6225934 times.
6472400 && ((attack!=wSword && attack!=wWand) || !(itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5))
12230
2/2
✓ Branch 0 taken 6472386 times.
✓ Branch 1 taken 246452 times.
6472400 && charging!=0))
12231 {
12232 536672 return false;
12233 }
12234
12235 6472386 int32_t r = (isdungeon()) ? 16 : 0;
12236 6472386 int32_t r2 = get_bit(quest_rules, qr_NOBORDER) ? 0 : 8;
12237
12238
4/5
✓ Branch 0 taken 2536498 times.
✓ Branch 1 taken 3935888 times.
✓ Branch 2 taken 1700898 times.
✓ Branch 3 taken 2234990 times.
✗ Branch 4 not taken.
6472386 if(!get_bit(quest_rules, qr_ITEMSONEDGES)) switch(dir)
12239 {
12240 case up:
12241 case down:
12242
2/2
✓ Branch 0 taken 1650906 times.
✓ Branch 1 taken 49992 times.
1700898 return !(y<(r2+r) || y>(160-r-r2));
12243
12244 case left:
12245 case right:
12246
2/2
✓ Branch 0 taken 2184636 times.
✓ Branch 1 taken 50354 times.
2234990 return !(x<(r2+r) || x>(240-r-r2));
12247 }
12248
12249 2536498 return true;
12250 7009058 }
12251
12252 2535 bool isRaftFlag(int32_t flag)
12253 {
12254
4/4
✓ Branch 0 taken 1208 times.
✓ Branch 1 taken 1327 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 1190 times.
2535 return (flag==mfRAFT || flag==mfRAFT_BRANCH || flag==mfRAFT_BOUNCE);
12255 }
12256
12257 3277702 void handle_lens_triggers(int32_t l_id)
12258 {
12259
2/2
✓ Branch 0 taken 3273595 times.
✓ Branch 1 taken 4107 times.
3277702 bool enabled = l_id >= 0 && (itemsbuf[l_id].flags & ITEM_FLAG6);
12260
2/2
✓ Branch 0 taken 3277702 times.
✓ Branch 1 taken 22943914 times.
26221616 for(auto layer = 0; layer < 7; ++layer)
12261 {
12262 22943914 mapscr* tmp = FFCore.tempScreens[layer];
12263
2/2
✓ Branch 0 taken 4038128864 times.
✓ Branch 1 taken 22943914 times.
4061072778 for(auto pos = 0; pos < 176; ++pos)
12264 {
12265 4038128864 newcombo const& cmb = combobuf[tmp->data[pos]];
12266
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4038128864 times.
✓ Branch 2 taken 4038128864 times.
✗ Branch 3 not taken.
4038128864 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
12267 4038128864 : (cmb.triggerflags[1] & combotriggerLENSOFF))
12268 {
12269 do_trigger_combo(layer, pos);
12270 }
12271 4038128864 }
12272 22943914 }
12273
2/2
✓ Branch 0 taken 3134331 times.
✓ Branch 1 taken 143371 times.
3277702 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
12274 {
12275 143371 word c = tmpscr->numFFC();
12276
2/2
✓ Branch 0 taken 143371 times.
✓ Branch 1 taken 800965 times.
944336 for(word i=0; i<c; i++)
12277 {
12278 800965 ffcdata& ffc = tmpscr->ffcs[i];
12279 800965 newcombo const& cmb = combobuf[ffc.getData()];
12280
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 800965 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 800965 times.
800965 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
12281 800965 : (cmb.triggerflags[1] & combotriggerLENSOFF))
12282 {
12283 do_trigger_combo_ffc(i);
12284 break;
12285 }
12286 800965 }
12287 143371 }
12288 3277702 }
12289
12290 3277702 void do_lens()
12291 {
12292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3277702 times.
3277702 if ( FFCore.getQuestHeaderInfo(vZelda) < 0x250 ) //2.10 or earlier
12293 {
12294 do_210_lens();
12295 return;
12296 }
12297
12298 3277702 int32_t wpnPressed = getWpnPressed(itype_lens);
12299
6/6
✓ Branch 0 taken 4105 times.
✓ Branch 1 taken 3273597 times.
✓ Branch 2 taken 363 times.
✓ Branch 3 taken 3273234 times.
✓ Branch 4 taken 351278 times.
✓ Branch 5 taken 2921956 times.
3277702 int32_t itemid = lensid >= 0 ? lensid : wpnPressed>0 ? wpnPressed : Hero.getLastLensID()>0 ? Hero.getLastLensID() : current_item_id(itype_lens);
12300
2/2
✓ Branch 0 taken 2555739 times.
✓ Branch 1 taken 721963 times.
3277702 if(itemid >= 0)
12301 {
12302
8/10
✓ Branch 0 taken 3246 times.
✓ Branch 1 taken 718717 times.
✓ Branch 2 taken 3246 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 512 times.
✓ Branch 5 taken 2734 times.
✓ Branch 6 taken 512 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 166 times.
✓ Branch 9 taken 346 times.
721963 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkbunny(itemid) && checkmagiccost(itemid))
12303 {
12304
2/2
✓ Branch 0 taken 149 times.
✓ Branch 1 taken 197 times.
346 if(lensid<0)
12305 {
12306 197 lensid=itemid;
12307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 197 times.
197 if(itemsbuf[itemid].family == itype_lens)
12308 197 Hero.setLastLensID(itemid);
12309
1/2
✓ Branch 0 taken 197 times.
✗ Branch 1 not taken.
197 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
12310 197 }
12311
12312 346 paymagiccost(itemid, true); //Needs to ignore timer cause lensclk is our timer.
12313
12314
2/10
✓ Branch 0 taken 346 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 346 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
346 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
12315 {
12316 //clear the item script stack for a new script
12317 //itemScriptData[(itemid & 0xFFF)].Clear();
12318 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(itemid & 0xFFF)][q] = 0;
12319 ri = &(itemScriptData[itemid]);
12320 for ( int32_t q = 0; q < 1024; q++ ) item_stack[itemid][q] = 0xFFFF;
12321 ri->Clear();
12322 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid & 0xFFF);
12323 item_doscript[itemid] = 1;
12324 itemscriptInitialised[itemid] = 0;
12325 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid);
12326 did_scriptl=true;
12327 }
12328
12329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 346 times.
346 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
12330 346 else lensclk = 12;
12331 346 }
12332 else
12333 {
12334 721617 did_scriptl=false;
12335
2/2
✓ Branch 0 taken 3761 times.
✓ Branch 1 taken 717856 times.
721617 if(!lensclk)
12336 {
12337
12338
2/2
✓ Branch 0 taken 717661 times.
✓ Branch 1 taken 195 times.
717856 if(lensid>-1)
12339 {
12340 195 lensid=-1;
12341 195 lensclk = 0;
12342
12343
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
12344 195 }
12345 717856 }
12346 }
12347 721963 }
12348 3277702 handle_lens_triggers(lensid);
12349 3277702 }
12350 //Add 2.10 version check to call this
12351 void do_210_lens()
12352 {
12353 int32_t itemid = lensid >= 0 ? lensid : directWpn>-1 ? directWpn : current_item_id(itype_lens);
12354
12355 if(itemid<0)
12356 return;
12357
12358 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkmagiccost(itemid))
12359 {
12360 if(lensid<0)
12361 {
12362 lensid=itemid;
12363
12364 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
12365 }
12366
12367 paymagiccost(itemid, true);
12368
12369 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
12370 {
12371 //clear the item script stack for a new script
12372 //itemScriptData[(itemid & 0xFFF)].Clear();
12373 ri = &(itemScriptData[itemid]);
12374 for ( int32_t q = 0; q < 1024; q++ ) item_stack[itemid][q] = 0xFFFF;
12375 ri->Clear();
12376 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(itemid & 0xFFF)][q] = 0;
12377 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid & 0xFFF);
12378 item_doscript[itemid] = 1;
12379 itemscriptInitialised[itemid] = 0;
12380 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid);
12381 did_scriptl=true;
12382 }
12383
12384 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
12385 else lensclk = 12;
12386 }
12387 else
12388 {
12389 did_scriptl=false;
12390
12391 if(lensid>-1 && !(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && checkmagiccost(itemid)))
12392 {
12393 lensid=-1;
12394 lensclk = 0;
12395
12396 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
12397 }
12398 }
12399 }
12400
12401 2455 void HeroClass::do_hopping()
12402 {
12403 2455 do_lens();
12404
12405
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 2385 times.
2455 if(hopclk==0xFF) //|| (diagonalMovement && hopclk >= 0xFF) )) // swimming
12406 //Possible fix for exiting water in diagonal movement. -Z
12407 {
12408 70 int32_t flippers_id = current_item_id(itype_flippers);
12409
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 68 times.
70 if(diveclk>0)
12410 {
12411 2 --diveclk;
12412
2/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && DrunkrAbtn()) //Cancellable Diving -V
12413 {
12414 diveclk = itemsbuf[flippers_id].misc2;
12415 }
12416 2 }
12417
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 else if(DrunkrAbtn())
12418 {
12419 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
12420 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
12421
12422 if(global_diving==screen_diving)
12423 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
12424 }
12425
12426
3/6
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
70 if((!(x.getInt()&7) && !(y.getInt()&7)) || (diagonalMovement||NO_GRIDLOCK))
12427 {
12428 70 SetSwim();
12429 70 hopclk = 0;
12430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if (!IsSideSwim())
12431 {
12432 70 charging = attackclk = 0;
12433 70 tapping = false;
12434 70 }
12435 70 }
12436 else
12437 {
12438 herostep();
12439
12440 if(!isDiving() || (frame&1))
12441 {
12442 switch(dir)
12443 {
12444 case up:
12445 y -= 1;
12446 break;
12447
12448 case down:
12449 y += 1;
12450 break;
12451
12452 case left:
12453 x -= 1;
12454 break;
12455
12456 case right:
12457 x += 1;
12458 break;
12459 }
12460 }
12461 }
12462 70 }
12463 else // hopping in or out (need to separate the cases...)
12464 {
12465
2/4
✓ Branch 0 taken 2385 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2385 times.
2385 if((diagonalMovement||NO_GRIDLOCK))
12466 {
12467 if(hopclk==1) //hopping out
12468 //>= 1 possible fix for getting stuck on land edges.
12469 //No, this is not a clock. it's a type. 1 == out, 2 == in.
12470 {
12471 if(hopdir!=-1) dir=hopdir;
12472
12473 landswim=0;
12474
12475 if(dir==up)
12476 {
12477 herostep();
12478 herostep();
12479 int32_t sidestep=0;
12480
12481 if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12482 sidestep=1;
12483 else if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12484 sidestep=2;
12485
12486 if(sidestep==1) x++;
12487 else if(sidestep==2) x--;
12488 else y--;
12489
12490 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12491 {
12492 hopclk=0;
12493 diveclk=0;
12494 action=none; FFCore.setHeroAction(none);
12495 hopdir=-1;
12496 }
12497 }
12498
12499 if(dir==down)
12500 {
12501 herostep();
12502 herostep();
12503 int32_t sidestep=0;
12504
12505 if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12506 sidestep=1;
12507 else if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12508 sidestep=2;
12509
12510 if(sidestep==1) x++;
12511 else if(sidestep==2) x--;
12512 else y++;
12513
12514 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12515 {
12516 hopclk=0;
12517 diveclk=0;
12518 action=none; FFCore.setHeroAction(none);
12519 hopdir=-1;
12520 }
12521 }
12522
12523 if(dir==left)
12524 {
12525 herostep();
12526 herostep();
12527 int32_t sidestep=0;
12528
12529 if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12530 sidestep=1;
12531 else if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12532 sidestep=2;
12533
12534 if(sidestep==1) y++;
12535 else if(sidestep==2) y--;
12536 else x--;
12537
12538 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12539 {
12540 hopclk=0;
12541 diveclk=0;
12542 action=none; FFCore.setHeroAction(none);
12543 hopdir=-1;
12544 }
12545 }
12546
12547 if(dir==right)
12548 {
12549 herostep();
12550 herostep();
12551 int32_t sidestep=0;
12552
12553 if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12554 sidestep=1;
12555 else if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12556 sidestep=2;
12557
12558 if(sidestep==1) y++;
12559 else if(sidestep==2) y--;
12560 else x++;
12561
12562 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12563 {
12564 hopclk=0;
12565 diveclk=0;
12566 action=none; FFCore.setHeroAction(none);
12567 hopdir=-1;
12568 }
12569 }
12570 }
12571
12572 if(hopclk==2) //hopping in
12573 {
12574 landswim=0;
12575
12576 if(dir==up)
12577 {
12578 herostep();
12579 herostep();
12580 int32_t sidestep=0;
12581
12582 if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12583 sidestep=1;
12584 else if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12585 sidestep=2;
12586
12587 if(sidestep==1) x++;
12588 else if(sidestep==2) x--;
12589 else y--;
12590
12591 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12592 {
12593 hopclk=0xFF;
12594 diveclk=0;
12595 SetSwim();
12596 }
12597 }
12598
12599 if(dir==down)
12600 {
12601 herostep();
12602 herostep();
12603 int32_t sidestep=0;
12604
12605 if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12606 sidestep=1;
12607 else if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12608 sidestep=2;
12609
12610 if(sidestep==1) x++;
12611 else if(sidestep==2) x--;
12612 else y++;
12613
12614 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12615 {
12616 hopclk=0xFF;
12617 diveclk=0;
12618 SetSwim();
12619 if (!IsSideSwim()) reset_swordcharge();
12620 }
12621 }
12622
12623 if(dir==left)
12624 {
12625 herostep();
12626 herostep();
12627 int32_t sidestep=0;
12628
12629 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12630 sidestep=1;
12631 else if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12632 sidestep=2;
12633
12634 if(sidestep==1) y++;
12635 else if(sidestep==2) y--;
12636 else x--;
12637
12638 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12639 {
12640 hopclk=0xFF;
12641 diveclk=0;
12642 SetSwim();
12643 }
12644 }
12645
12646 if(dir==right)
12647 {
12648 herostep();
12649 herostep();
12650
12651 int32_t sidestep=0;
12652
12653 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12654 sidestep=1;
12655 else if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12656 sidestep=2;
12657
12658 if(sidestep==1) y++;
12659 else if(sidestep==2) y--;
12660 else x++;
12661
12662 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12663 {
12664 hopclk=0xFF;
12665 diveclk=0;
12666 SetSwim();
12667 }
12668 }
12669 }
12670
12671 }
12672 else
12673 {
12674
7/8
✓ Branch 0 taken 892 times.
✓ Branch 1 taken 1493 times.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 657 times.
✓ Branch 5 taken 235 times.
✓ Branch 6 taken 129 times.
✓ Branch 7 taken 1364 times.
2385 if((dir<left ? !(x.getInt()&7) && !(y.getInt()&15) : !(x.getInt()&15) && !(y.getInt()&7)))
12675 {
12676 235 action=none; FFCore.setHeroAction(none);
12677 235 hopclk = 0;
12678 235 diveclk = 0;
12679
12680
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 118 times.
235 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+8), currmap, currscr, -1, x.getInt(),y.getInt()+8, true, false))
12681 {
12682 // hopped in
12683 118 SetSwim();
12684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
118 if (!IsSideSwim()) attackclk = charging = spins = 0;
12685 118 }
12686 235 }
12687 else
12688 {
12689 2150 herostep();
12690 2150 herostep();
12691
12692
2/2
✓ Branch 0 taken 2023 times.
✓ Branch 1 taken 127 times.
2150 if(++hero_count>(16*hero_animation_speed))
12693 127 hero_count=0;
12694
12695 2150 int32_t xofs2 = x.getInt()&15;
12696 2150 int32_t yofs2 = y.getInt()&15;
12697 2150 int32_t s = 1 + (frame&1);
12698
12699
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
✓ Branch 2 taken 508 times.
✓ Branch 3 taken 600 times.
✓ Branch 4 taken 764 times.
2150 switch(dir)
12700 {
12701 case up:
12702
3/4
✓ Branch 0 taken 191 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
278 if(yofs2<3 || yofs2>13) --y;
12703 191 else y-=s;
12704
12705 278 break;
12706
12707 case down:
12708
4/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 76 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 360 times.
508 if(yofs2<3 || yofs2>13) ++y;
12709 360 else y+=s;
12710
12711 508 break;
12712
12713 case left:
12714
4/4
✓ Branch 0 taken 524 times.
✓ Branch 1 taken 76 times.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 437 times.
600 if(xofs2<3 || xofs2>13) --x;
12715 437 else x-=s;
12716
12717 600 break;
12718
12719 case right:
12720
4/4
✓ Branch 0 taken 648 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 540 times.
764 if(xofs2<3 || xofs2>13) ++x;
12721 540 else x+=s;
12722
12723 764 break;
12724 }
12725 }
12726 }
12727 }
12728 2455 }
12729
12730 17170 void HeroClass::do_rafting()
12731 {
12732
12733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17170 times.
17170 if(toogam)
12734 {
12735 action=none; FFCore.setHeroAction(none);
12736 return;
12737 }
12738
12739 17170 FFCore.setHeroAction(rafting);
12740
12741 17170 do_lens();
12742
12743 17170 herostep();
12744
12745 //Calculate rafting speed
12746 17170 int32_t raft_item = current_item_id(itype_raft);
12747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17170 times.
17170 int32_t raft_step = (raft_item < 0 ? 1 : itemsbuf[raft_item].misc1);
12748 17170 raft_step = vbound(raft_step, -8, 5);
12749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17170 times.
17170 int32_t raft_time = raft_step < 0 ? 1<<(-raft_step) : 1;
12750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17170 times.
17170 if(raft_step < 0) raft_step = 1;
12751 17170 int32_t step_inc = 1 << (raft_step - 1);
12752 // Fix position
12753
1/2
✓ Branch 0 taken 17170 times.
✗ Branch 1 not taken.
17170 if(raft_step > 1)
12754 {
12755 if(x.getInt() & (step_inc-1))
12756 {
12757 x = x.getInt() & ~(step_inc-1);
12758 }
12759 if(y.getInt() & (step_inc-1))
12760 {
12761 y = y.getInt() & ~(step_inc-1);
12762 }
12763 }
12764 // Inc clock, check if we need to move this frame
12765 17170 ++raftclk;
12766
2/4
✓ Branch 0 taken 17170 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17170 times.
17170 if((raftclk % raft_time) || raft_step == 0) return; //No movement this frame
12767
12768
4/4
✓ Branch 0 taken 7795 times.
✓ Branch 1 taken 9375 times.
✓ Branch 2 taken 6514 times.
✓ Branch 3 taken 1281 times.
18446 if(!(x.getInt()&15) && !(y.getInt()&15))
12769 {
12770 // this sections handles switching to raft branches
12771
3/4
✓ Branch 0 taken 1264 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1264 times.
1281 if((MAPFLAG(x,y)==mfRAFT_BRANCH||MAPCOMBOFLAG(x,y)==mfRAFT_BRANCH))
12772 {
12773
5/8
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17 if(dir!=down && DrunkUp() && (isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
12774 {
12775 3 dir = up;
12776 3 goto skip;
12777 }
12778
12779
2/8
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14 if(dir!=up && DrunkDown() && (isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
12780 {
12781 dir = down;
12782 goto skip;
12783 }
12784
12785
5/8
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14 if(dir!=right && DrunkLeft() && (isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
12786 {
12787 1 dir = left;
12788 1 goto skip;
12789 }
12790
12791
4/8
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
13 if(dir!=left && DrunkRight() && (isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
12792 {
12793 1 dir = right;
12794 1 goto skip;
12795 }
12796 12 }
12797
2/4
✓ Branch 0 taken 1264 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1264 times.
1264 else if((MAPFLAG(x,y)==mfRAFT_BOUNCE||MAPCOMBOFLAG(x,y)==mfRAFT_BOUNCE))
12798 {
12799 if(dir == left) dir = right;
12800 else if(dir == right) dir = left;
12801 else if(dir == up) dir = down;
12802 else if(dir == down) dir = up;
12803 }
12804
12805
12806
3/4
✓ Branch 0 taken 191 times.
✓ Branch 1 taken 1085 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 191 times.
1276 if(!isRaftFlag(nextflag(x,y,dir,false))&&!isRaftFlag(nextflag(x,y,dir,true)))
12807 {
12808
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 85 times.
191 if(dir<left) //going up or down
12809 {
12810
3/4
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 101 times.
106 if((isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
12811 5 dir=right;
12812
3/4
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86 times.
101 else if((isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
12813 15 dir=left;
12814
4/4
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 7 times.
86 else if(y>0 && y<160)
12815 {
12816 72 action=none; FFCore.setHeroAction(none);
12817 72 x = x.getInt();
12818 72 y = y.getInt();
12819 72 }
12820 106 }
12821 else //going left or right
12822 {
12823
3/4
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68 times.
85 if((isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
12824 17 dir=down;
12825
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
68 else if((isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
12826 6 dir=up;
12827
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
62 else if(x>0 && x<240)
12828 {
12829 62 action=none; FFCore.setHeroAction(none);
12830 62 x = x.getInt();
12831 62 y = y.getInt();
12832 62 }
12833 }
12834 191 }
12835 1276 }
12836
12837 skip:
12838
12839
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3610 times.
✓ Branch 2 taken 3451 times.
✓ Branch 3 taken 4768 times.
✓ Branch 4 taken 5341 times.
17170 switch(dir)
12840 {
12841 case up:
12842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3610 times.
3610 if(x.getInt()&15)
12843 {
12844 if(x.getInt()&8)
12845 x++;
12846 else x--;
12847 }
12848 3610 else y -= step_inc;
12849
12850 3610 break;
12851
12852 case down:
12853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3451 times.
3451 if(x.getInt()&15)
12854 {
12855 if(x.getInt()&8)
12856 x++;
12857 else x--;
12858 }
12859 3451 else y += step_inc;
12860
12861 3451 break;
12862
12863 case left:
12864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4768 times.
4768 if(y.getInt()&15)
12865 {
12866 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
12867 {
12868 if ((y.getInt() % 16) < 4) y--;
12869 else y++;
12870 }
12871 else
12872 {
12873 if(y.getInt()&8)
12874 y++;
12875 else y--;
12876 }
12877 }
12878 4768 else x -= step_inc;
12879
12880 4768 break;
12881
12882 case right:
12883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5341 times.
5341 if(y.getInt()&15)
12884 {
12885 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
12886 {
12887 if ((y.getInt() % 16) <= 4) y--;
12888 else y++;
12889 }
12890 else
12891 {
12892 if(y.getInt()&8)
12893 y++;
12894 else y--;
12895 }
12896 }
12897 5341 else x += step_inc;
12898
12899 5341 break;
12900 }
12901 17170 }
12902
12903 7 bool HeroClass::try_hover()
12904 {
12905
2/10
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
7 if(hoverclk <= 0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
12906 {
12907 int32_t itemid = current_item_id(itype_hoverboots);
12908 if(hoverclk < 0)
12909 hoverclk = -hoverclk;
12910 else
12911 {
12912 fall = fakefall = jumping = 0;
12913 if(itemsbuf[itemid].misc1)
12914 hoverclk = itemsbuf[itemid].misc1;
12915 else
12916 {
12917 hoverclk = 1;
12918 hoverflags |= HOV_INF;
12919 }
12920
12921
12922 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
12923 }
12924 if(itemsbuf[itemid].wpn)
12925 decorations.add(new dHover(x, y, dHOVER, 0));
12926 return true;
12927 }
12928 7 return false;
12929 7 }
12930
12931 //Returns bitwise; lower 8 are dir pulled in, next 16 are combo ID, 25th bit is bool for if can be resisted
12932 //Returns '-1' if not being pulled
12933 //Returns '-2' if should be falling in
12934 13076631 int32_t HeroClass::check_pitslide(bool ignore_hover)
12935 {
12936 //Pitfall todo -Emily
12937 //Iron boots; can't fight slipping, 2px/frame
12938 //Scripted variables to read pull dir/clk (clk only for non-hero)
12939 //Implement falling for all sprite types (npc AI)
12940 // Fall/slipping tiles for enemies
12941 // Fall/slipping SFX for enemies
12942 // Fall SFX for items/weapons
12943 // Weapons/Misc sprite shared for falling items/weapons
12944 //Maybe slip SFX for Hero?
12945 // Weapons/Misc sprite override for falling sprite?
12946 //Update std.zh with relevant new stuff
12947
2/2
✓ Branch 0 taken 389458 times.
✓ Branch 1 taken 12687173 times.
13076631 if(can_pitfall(ignore_hover))
12948 {
12949
2/2
✓ Branch 0 taken 942025 times.
✓ Branch 1 taken 11745148 times.
12687173 bool can_diag = (diagonalMovement || get_bit(quest_rules,qr_DISABLE_4WAY_GRIDLOCK));
12950 12687173 int32_t ispitul = getpitfall(x,y+(bigHitbox?0:8));
12951 12687173 int32_t ispitbl = getpitfall(x,y+15);
12952 12687173 int32_t ispitur = getpitfall(x+15,y+(bigHitbox?0:8));
12953 12687173 int32_t ispitbr = getpitfall(x+15,y+15);
12954 12687173 int32_t ispitul_50 = getpitfall(x+8,y+(bigHitbox?8:12));
12955 12687173 int32_t ispitbl_50 = getpitfall(x+8,y+(bigHitbox?7:11));
12956 12687173 int32_t ispitur_50 = getpitfall(x+7,y+(bigHitbox?8:12));
12957 12687173 int32_t ispitbr_50 = getpitfall(x+7,y+(bigHitbox?7:11));
12958 12687173 int32_t ispitul_75 = getpitfall(x+12,y+(bigHitbox?12:14));
12959 12687173 int32_t ispitbl_75 = getpitfall(x+12,y+(bigHitbox?3:9));
12960 12687173 int32_t ispitur_75 = getpitfall(x+3,y+(bigHitbox?12:14));
12961 12687173 int32_t ispitbr_75 = getpitfall(x+3,y+(bigHitbox?3:9));
12962 static const int32_t flag_pit_irresistable = (1<<24);
12963
5/5
✓ Branch 0 taken 12680950 times.
✓ Branch 1 taken 673 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 2810 times.
✓ Branch 4 taken 2666 times.
12687173 switch((ispitul?1:0) + (ispitur?1:0) + (ispitbl?1:0) + (ispitbr?1:0))
12964 {
12965 673 case 4: return -2; //Fully over pit; fall in
12966 case 3:
12967 {
12968
2/6
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 74 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
74 if(ispitul && ispitur && ispitbl) //UL_3
12969 {
12970 if(ispitul_50)
12971 {
12972 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
12973 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
12974 }
12975 }
12976
2/6
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 74 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
74 else if(ispitul && ispitur && ispitbr) //UR_3
12977 {
12978 if(ispitur_50)
12979 {
12980 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
12981 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
12982 }
12983 }
12984
3/6
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 74 times.
74 else if(ispitul && ispitbl && ispitbr) //BL_3
12985 {
12986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(ispitbl_50)
12987 {
12988 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
12989 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
12990 }
12991 74 }
12992 else if(ispitbl && ispitur && ispitbr) //BR_3
12993 {
12994 if(ispitbr_50)
12995 {
12996 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
12997 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
12998 }
12999 }
13000 74 break;
13001 }
13002 case 2:
13003 {
13004
4/4
✓ Branch 0 taken 1212 times.
✓ Branch 1 taken 1598 times.
✓ Branch 2 taken 1208 times.
✓ Branch 3 taken 4 times.
2810 if(ispitul && ispitur) //Up
13005 {
13006
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(DrunkDown())
13007 {
13008
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if(ispitul_75 && ispitur_75) //Straight up
13009 {
13010 return up | flag_pit_irresistable | (ispitul << 8);
13011 }
13012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 else if(ispitul_75)
13013 {
13014 return (can_diag ? l_up : left) | flag_pit_irresistable | (ispitul << 8);
13015 }
13016
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 else if(ispitur_75)
13017 {
13018 return (can_diag ? r_up : right) | flag_pit_irresistable | (ispitur << 8);
13019 }
13020 4 else return -1;
13021 }
13022 else
13023 {
13024 if(ispitul_50 && ispitur_50) //Straight up
13025 {
13026 return up | ((ispitul_75 || ispitur_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
13027 }
13028 else if(ispitul_50)
13029 {
13030 if(DrunkRight() && !ispitul_75) return -1;
13031 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13032 }
13033 else if(ispitur_50)
13034 {
13035 if(DrunkLeft() && !ispitur_75) return -1;
13036 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13037 }
13038 }
13039 }
13040
4/4
✓ Branch 0 taken 1510 times.
✓ Branch 1 taken 1296 times.
✓ Branch 2 taken 1208 times.
✓ Branch 3 taken 302 times.
2806 else if(ispitbl && ispitbr) //Down
13041 {
13042
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 290 times.
302 if(DrunkUp())
13043 {
13044
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(ispitbl_75 && ispitbr_75) //Straight down
13045 {
13046 return down | flag_pit_irresistable | (ispitbl << 8);
13047 }
13048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 else if(ispitbl_75)
13049 {
13050 return (can_diag ? l_down : left) | flag_pit_irresistable | (ispitbl << 8);
13051 }
13052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 else if(ispitbr_75)
13053 {
13054 return (can_diag ? r_down : right) | flag_pit_irresistable | (ispitbr << 8);
13055 }
13056 12 else return -1;
13057 }
13058 else
13059 {
13060
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 290 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
290 if(ispitbl_50 && ispitbr_50) //Straight down
13061 {
13062 return down | ((ispitbl_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitbl << 8);
13063 }
13064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 290 times.
290 else if(ispitbl_50)
13065 {
13066 if(DrunkRight() && !ispitbl_75) return -1;
13067 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13068 }
13069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 290 times.
290 else if(ispitbr_50)
13070 {
13071 if(DrunkLeft() && !ispitbr_75) return -1;
13072 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13073 }
13074 }
13075 290 }
13076
3/4
✓ Branch 0 taken 1208 times.
✓ Branch 1 taken 1296 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1208 times.
2504 else if(ispitbl && ispitul) //Left
13077 {
13078
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 1125 times.
1208 if(DrunkRight())
13079 {
13080
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
83 if(ispitul_75 && ispitbl_75) //Straight left
13081 {
13082 return left | flag_pit_irresistable | (ispitul << 8);
13083 }
13084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 else if(ispitul_75)
13085 {
13086 return (can_diag ? l_up : up) | flag_pit_irresistable | (ispitul << 8);
13087 }
13088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 else if(ispitbl_75)
13089 {
13090 return (can_diag ? l_down : down) | flag_pit_irresistable | (ispitbl << 8);
13091 }
13092 83 else return -1;
13093 }
13094 else
13095 {
13096
3/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1104 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
1125 if(ispitul_50 && ispitbl_50) //Straight left
13097 {
13098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 return left | ((ispitul_75 || ispitbl_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
13099 }
13100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1104 times.
1104 else if(ispitul_50)
13101 {
13102 if(DrunkDown() && !ispitul_75) return -1;
13103 return (can_diag ? l_up : up) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13104 }
13105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1104 times.
1104 else if(ispitbl_50)
13106 {
13107 if(DrunkUp() && !ispitbl_75) return -1;
13108 return (can_diag ? l_down : down) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13109 }
13110 }
13111 1104 }
13112
2/4
✓ Branch 0 taken 1296 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1296 times.
1296 else if(ispitbr && ispitur) //Right
13113 {
13114
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 1184 times.
1296 if(DrunkLeft())
13115 {
13116
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
112 if(ispitur_75 && ispitbr_75) //Straight right
13117 {
13118 return right | flag_pit_irresistable | (ispitur << 8);
13119 }
13120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 else if(ispitur_75)
13121 {
13122 return (can_diag ? r_up : up) | flag_pit_irresistable | (ispitur << 8);
13123 }
13124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 else if(ispitbr_75)
13125 {
13126 return (can_diag ? r_down : down) | flag_pit_irresistable | (ispitbr << 8);
13127 }
13128 112 else return -1;
13129 }
13130 else
13131 {
13132
3/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1168 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
1184 if(ispitur_50 && ispitbr_50) //Straight right
13133 {
13134
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
16 return right | ((ispitur_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitur << 8);
13135 }
13136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1168 times.
1168 else if(ispitur_50)
13137 {
13138 if(DrunkDown() && !ispitur_75) return -1;
13139 return (can_diag ? r_up : up) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13140 }
13141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1168 times.
1168 else if(ispitbr_50)
13142 {
13143 if(DrunkUp() && !ispitbr_75) return -1;
13144 return (can_diag ? r_down : down) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13145 }
13146 }
13147 1168 }
13148 2562 break;
13149 }
13150 case 1:
13151 {
13152
3/4
✓ Branch 0 taken 940 times.
✓ Branch 1 taken 1726 times.
✓ Branch 2 taken 940 times.
✗ Branch 3 not taken.
2666 if(ispitul && ispitul_50) //UL_1
13153 {
13154 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
13155 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13156 }
13157
3/4
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 2246 times.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
2666 if(ispitur && ispitur_50) //UR_1
13158 {
13159 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
13160 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13161 }
13162
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 2490 times.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
2666 if(ispitbl && ispitbl_50) //BL_1
13163 {
13164 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
13165 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13166 }
13167
3/4
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 1130 times.
✗ Branch 3 not taken.
2666 if(ispitbr && ispitbr_50) //BR_1
13168 {
13169 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
13170 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13171 }
13172 2666 break;
13173 }
13174 }
13175 12686252 }
13176 13075710 return -1;
13177 13076631 }
13178
13179 2752350 bool HeroClass::pitslide() //Runs pitslide movement; returns true if pit is irresistable
13180 {
13181 2752350 pitfall();
13182
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2752348 times.
2752350 if(fallclk) return true;
13183 2752348 int32_t val = check_pitslide();
13184 //Val should not be -2 here; if -2 would have been returned, the 'return true' above should have triggered!
13185
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2752344 times.
2752348 if(val == -1)
13186 {
13187 2752344 pit_pulldir = -1;
13188 2752344 pit_pullclk = 0;
13189 2752344 return false;
13190 }
13191 4 int32_t dir = val&0xFF;
13192 4 int32_t cmbid = (val&0xFFFF00)>>8;
13193 4 int32_t sensitivity = combobuf[cmbid].attribytes[2];
13194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(combobuf[cmbid].usrflags&cflag5) //No pull at all
13195 {
13196 pit_pulldir = -1;
13197 pit_pullclk = 0;
13198 return false;
13199 }
13200
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 if(dir > -1 && !(hoverflags & HOV_PITFALL_OUT) && try_hover()) //Engage hovers
13201 {
13202 pit_pulldir = -1;
13203 pit_pullclk = 0;
13204 return false;
13205 }
13206 4 pit_pulldir = dir;
13207 4 int32_t step = 1;
13208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(sensitivity == 0)
13209 {
13210 4 step = 2;
13211 4 sensitivity = 1;
13212 4 }
13213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(pit_pullclk++ % sensitivity) //No pull this frame
13214 return (val&0x100);
13215
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 4 times.
11 for(; step > 0 && !fallclk; --step)
13216 {
13217
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 switch(dir)
13218 {
13219 case l_up: case l_down: case left:
13220 --x; break;
13221 case r_up: case r_down: case right:
13222 7 ++x; break;
13223 }
13224
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
7 switch(dir)
13225 {
13226 case l_up: case r_up: case up:
13227 --y; break;
13228 case l_down: case r_down: case down:
13229 ++y; break;
13230 }
13231 7 pitfall();
13232 7 }
13233
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 return fallclk || (val&0x100);
13234 2752350 }
13235
13236 2752567 void HeroClass::pitfall()
13237 {
13238
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 2752357 times.
2752567 if(fallclk)
13239 {
13240 210 drop_liftwpn();
13241
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
210 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
13242 //Handle falling
13243
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 3 times.
210 if(!--fallclk)
13244 {
13245 3 int32_t dmg = game->get_hp_per_heart()/4;
13246 3 bool dmg_perc = false;
13247 3 bool warp = false;
13248
13249 3 action=none; FFCore.setHeroAction(none);
13250
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 newcombo* cmb = fallCombo ? &combobuf[fallCombo] : NULL;
13251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(cmb)
13252 {
13253 3 dmg = cmb->attributes[0]/10000L;
13254 3 dmg_perc = cmb->usrflags&cflag3;
13255 3 warp = cmb->usrflags&cflag1;
13256 3 }
13257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(dmg) //Damage
13258 {
13259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(dmg > 0) hclk=48; //IFrames only if damaged, not if healed
13260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 game->set_life(vbound(int32_t(dmg_perc ? game->get_life() - ((vbound(dmg,-100,100)/100.0)*game->get_maxlife()) : (game->get_life()-int64_t(dmg))),0,game->get_maxlife()));
13261 3 }
13262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(warp) //Warp
13263 {
13264 sdir = dir;
13265 if(cmb->usrflags&cflag2) //Direct Warp
13266 {
13267 didpit=true;
13268 pitx=x;
13269 pity=y;
13270 }
13271 dowarp(0,vbound(cmb->attribytes[1],0,3),0);
13272 }
13273 else //Reset to screen entry
13274 {
13275 3 go_respawn_point();
13276 }
13277 3 }
13278 210 }
13279
2/2
✓ Branch 0 taken 83615 times.
✓ Branch 1 taken 2668742 times.
2752357 else if(can_pitfall())
13280 {
13281 2668742 bool ispitul = ispitfall(x,y+(bigHitbox?0:8));
13282 2668742 bool ispitbl = ispitfall(x,y+15);
13283 2668742 bool ispitur = ispitfall(x+15,y+(bigHitbox?0:8));
13284 2668742 bool ispitbr = ispitfall(x+15,y+15);
13285 2668742 int32_t pitctr = getpitfall(x+8,y+(bigHitbox?8:12));
13286
8/10
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 2668281 times.
✓ Branch 2 taken 244 times.
✓ Branch 3 taken 217 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 241 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 3 times.
2668742 if(ispitul && ispitbl && ispitur && ispitbr && pitctr)
13287 {
13288
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!(hoverflags & HOV_PITFALL_OUT) && try_hover()) return;
13289
3/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
3 if(!bigHitbox && !ispitfall(x,y)) y = (y.getInt() + 8 - (y.getInt() % 8)); //Make the falling sprite fully over the pit
13290 3 fallclk = PITFALL_FALL_FRAMES;
13291 3 fallCombo = pitctr;
13292 3 action=falling; FFCore.setHeroAction(falling);
13293 3 spins = 0;
13294 3 charging = 0;
13295 3 drop_liftwpn();
13296 3 }
13297 2668742 }
13298 2752567 }
13299
13300 3275113 void HeroClass::movehero()
13301 {
13302
2/4
✓ Branch 0 taken 3275113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3275113 times.
3275113 if(lstunclock || is_conveyor_stunned) return;
13303 3275113 int32_t xoff=x.getInt()&7;
13304 3275113 int32_t yoff=y.getInt()&7;
13305
2/2
✓ Branch 0 taken 3260206 times.
✓ Branch 1 taken 14907 times.
3275113 if(NO_GRIDLOCK)
13306 {
13307 14907 xoff = 0;
13308 14907 yoff = 0;
13309 14907 }
13310 3275113 int32_t push=pushing;
13311 3275113 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
13312 3275113 pushing=0;
13313 3275113 zfix temp_step(hero_newstep);
13314 3275113 zfix temp_x(x);
13315 3275113 zfix temp_y(y);
13316
13317 3275113 int32_t flippers_id = current_item_id(itype_flippers);
13318
2/2
✓ Branch 0 taken 2690 times.
✓ Branch 1 taken 3272423 times.
3275113 if(diveclk>0)
13319 {
13320
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2690 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2690 if (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM)) diveclk = 0;
13321 2690 --diveclk;
13322
4/8
✓ Branch 0 taken 1796 times.
✓ Branch 1 taken 894 times.
✓ Branch 2 taken 1796 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1796 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2690 if(isDiving() && flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && DrunkrAbtn()) //Cancellable Diving -V
13323 {
13324 diveclk = itemsbuf[flippers_id].misc2;
13325 }
13326 2690 }
13327
4/4
✓ Branch 0 taken 18339 times.
✓ Branch 1 taken 3254084 times.
✓ Branch 2 taken 18294 times.
✓ Branch 3 taken 45 times.
3272423 else if(action == swimming && DrunkrAbtn())
13328 {
13329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
13330 45 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
13331
13332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(global_diving==screen_diving)
13333
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
13334 45 }
13335
13336
2/2
✓ Branch 0 taken 3257943 times.
✓ Branch 1 taken 17170 times.
3275113 if(action==rafting)
13337 {
13338 17170 do_rafting();
13339
13340
2/2
✓ Branch 0 taken 17036 times.
✓ Branch 1 taken 134 times.
17170 if(action==rafting)
13341 {
13342 17036 return;
13343 }
13344
13345
13346 134 set_respawn_point();
13347 134 trySideviewLadder();
13348 134 }
13349
13350 3258077 int32_t olddirectwpn = directWpn; // To be reinstated if startwpn() fails
13351 3258077 int32_t btnwpn = -1;
13352
13353 //&0xFFF removes the "bow & arrows" bitmask
13354 //The Quick Sword is allowed to interrupt attacks.
13355
4/4
✓ Branch 0 taken 3177328 times.
✓ Branch 1 taken 80749 times.
✓ Branch 2 taken 2196306 times.
✓ Branch 3 taken 981022 times.
3258077 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
13356
8/8
✓ Branch 0 taken 2751622 times.
✓ Branch 1 taken 506455 times.
✓ Branch 2 taken 2748337 times.
✓ Branch 3 taken 3285 times.
✓ Branch 4 taken 124108 times.
✓ Branch 5 taken 385632 times.
✓ Branch 6 taken 33262 times.
✓ Branch 7 taken 476478 times.
3258077 if((!attackclk && action!=attacking && action != sideswimattacking) || ((attack==wSword || attack==wWand) && (itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5)))
13357 {
13358
2/2
✓ Branch 0 taken 8896 times.
✓ Branch 1 taken 2772703 times.
2781599 if(DrunkrBbtn())
13359 {
13360 8896 btnwpn=getItemFamily(itemsbuf,Bwpn&0xFFF);
13361 8896 dowpn = Bwpn&0xFFF;
13362 8896 directWpn = directItemB;
13363 8896 }
13364
2/2
✓ Branch 0 taken 28771 times.
✓ Branch 1 taken 2743932 times.
2772703 else if(DrunkrAbtn())
13365 {
13366 28771 btnwpn=getItemFamily(itemsbuf,Awpn&0xFFF);
13367 28771 dowpn = Awpn&0xFFF;
13368 28771 directWpn = directItemA;
13369 28771 }
13370
4/4
✓ Branch 0 taken 71669 times.
✓ Branch 1 taken 2672263 times.
✓ Branch 2 taken 71662 times.
✓ Branch 3 taken 7 times.
2743932 else if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) && DrunkrEx1btn())
13371 {
13372 7 btnwpn=getItemFamily(itemsbuf,Xwpn&0xFFF);
13373 7 dowpn = Xwpn&0xFFF;
13374 7 directWpn = directItemX;
13375 7 }
13376
4/4
✓ Branch 0 taken 71662 times.
✓ Branch 1 taken 2672263 times.
✓ Branch 2 taken 71557 times.
✓ Branch 3 taken 105 times.
2743925 else if(get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) && DrunkrEx2btn())
13377 {
13378 105 btnwpn=getItemFamily(itemsbuf,Ywpn&0xFFF);
13379 105 dowpn = Ywpn&0xFFF;
13380 105 directWpn = directItemY;
13381 105 }
13382
13383
1/2
✓ Branch 0 taken 2781599 times.
✗ Branch 1 not taken.
2781599 if(directWpn > 255) directWpn = 0;
13384
13385 // The Quick Sword only allows repeated sword or wand swings.
13386
7/8
✓ Branch 0 taken 2748337 times.
✓ Branch 1 taken 33262 times.
✓ Branch 2 taken 33262 times.
✓ Branch 3 taken 2748337 times.
✓ Branch 4 taken 32749 times.
✓ Branch 5 taken 513 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2748850 times.
2781599 if((action==attacking||action==sideswimattacking) && ((attack==wSword && btnwpn!=itype_sword) || (attack==wWand && btnwpn!=itype_wand)))
13387 32749 btnwpn=-1;
13388 2781599 }
13389
13390
2/2
✓ Branch 0 taken 3157740 times.
✓ Branch 1 taken 100337 times.
3258077 auto swordid = (directWpn>-1 ? directWpn : current_item_id(itype_sword));
13391
11/12
✓ Branch 0 taken 3133963 times.
✓ Branch 1 taken 124114 times.
✓ Branch 2 taken 3101627 times.
✓ Branch 3 taken 32336 times.
✓ Branch 4 taken 3027587 times.
✓ Branch 5 taken 74040 times.
✓ Branch 6 taken 2997340 times.
✓ Branch 7 taken 30247 times.
✓ Branch 8 taken 28457 times.
✓ Branch 9 taken 2968883 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 28457 times.
3258077 if(can_attack() && (swordid > -1 && itemsbuf[swordid].family==itype_sword) && checkitem_jinx(swordid) && btnwpn==itype_sword && charging==0)
13392 {
13393
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 28203 times.
28457 attackid=directWpn>-1 ? directWpn : current_item_id(itype_sword);
13394
4/6
✓ Branch 0 taken 28457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 28442 times.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
28457 if(checkbunny(attackid) && (checkmagiccost(attackid) || !(itemsbuf[attackid].flags & ITEM_FLAG6)))
13395 {
13396
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 28442 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
28442 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_SWORD_COST))
13397 {
13398 paymagiccost(attackid,true);
13399 misc_internal_hero_flags |= LF_PAID_SWORD_COST;
13400 }
13401 28442 SetAttack();
13402 28442 attack=wSword;
13403
13404 28442 attackclk=0;
13405
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 28203 times.
28442 sfx(itemsbuf[directWpn>-1 ? directWpn : current_item_id(itype_sword)].usesound, pan(x.getInt()));
13406
13407
2/10
✓ Branch 0 taken 28442 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 28442 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
28442 if(dowpn>-1 && itemsbuf[dowpn].script!=0 && !did_scripta && !(item_doscript[dowpn] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
13408 {
13409 if(!checkmagiccost(dowpn))
13410 {
13411 item_error();
13412 }
13413 else
13414 {
13415 //clear the item script stack for a new script
13416
13417 ri = &(itemScriptData[dowpn]);
13418 for ( int32_t q = 0; q < 1024; q++ ) item_stack[dowpn][q] = 0xFFFF;
13419 ri->Clear();
13420 //itemScriptData[(dowpn & 0xFFF)].Clear();
13421 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(dowpn & 0xFFF)][q] = 0;
13422 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn & 0xFFF);
13423 item_doscript[dowpn] = 1;
13424 itemscriptInitialised[dowpn] = 0;
13425 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn);
13426 did_scripta=true;
13427 }
13428 }
13429 28442 }
13430 else
13431 {
13432 15 item_error();
13433 }
13434 28457 }
13435 else
13436 {
13437 3229620 did_scripta=false;
13438 }
13439
13440
7/10
✓ Branch 0 taken 3237048 times.
✓ Branch 1 taken 21029 times.
✓ Branch 2 taken 3237048 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3237048 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3237048 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 214 times.
✓ Branch 9 taken 3236834 times.
3258077 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !getOnSideviewLadder())
13441 {
13442
4/4
✓ Branch 0 taken 540287 times.
✓ Branch 1 taken 2696547 times.
✓ Branch 2 taken 540282 times.
✓ Branch 3 taken 5 times.
3236834 if(DrunkUp() && canSideviewLadder())
13443 {
13444 5 setOnSideviewLadder(true);
13445 5 }
13446
3/4
✓ Branch 0 taken 443543 times.
✓ Branch 1 taken 2793286 times.
✓ Branch 2 taken 443543 times.
✗ Branch 3 not taken.
3236829 else if(DrunkDown() && canSideviewLadder(true))
13447 {
13448 y+=1;
13449 setOnSideviewLadder(true);
13450 }
13451 3236834 }
13452
13453 3258077 int32_t wx=x;
13454 3258077 int32_t wy=y;
13455
5/6
✓ Branch 0 taken 2333869 times.
✓ Branch 1 taken 924208 times.
✓ Branch 2 taken 219 times.
✓ Branch 3 taken 3257858 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 219 times.
3258077 if((action==none || action==walking) && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
13456 {
13457
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 219 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
219 if((xoff==0)||diagonalMovement)
13458 {
13459
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 180 times.
219 if(DrunkUp()) dir=up;
13460
1/2
✓ Branch 0 taken 219 times.
✗ Branch 1 not taken.
219 if(DrunkDown()) dir=down;
13461 219 }
13462
13463
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 219 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
219 if((yoff==0)||diagonalMovement)
13464 {
13465
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 23 times.
219 if(DrunkLeft()) dir=left;
13466
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 29 times.
219 if(DrunkRight()) dir=right;
13467 219 }
13468 219 }
13469
13470
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 774916 times.
✓ Branch 2 taken 649331 times.
✓ Branch 3 taken 887620 times.
✓ Branch 4 taken 946210 times.
3258077 switch(dir)
13471 {
13472 case up:
13473 774916 wy-=16;
13474 774916 break;
13475
13476 case down:
13477 649331 wy+=16;
13478 649331 break;
13479
13480 case left:
13481 887620 wx-=16;
13482 887620 break;
13483
13484 case right:
13485 946210 wx+=16;
13486 946210 break;
13487 }
13488
13489 3258077 do_lens();
13490
13491 3258077 WalkflagInfo info;
13492
13493 3258077 bool no_jinx = true;
13494
7/8
✓ Branch 0 taken 3133963 times.
✓ Branch 1 taken 124114 times.
✓ Branch 2 taken 8930 times.
✓ Branch 3 taken 3125033 times.
✓ Branch 4 taken 8930 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✓ Branch 7 taken 8897 times.
3258077 if(can_attack() && btnwpn>itype_sword && charging==0 && btnwpn!=itype_rupee) // This depends on item 0 being a rupee...
13495 {
13496 8897 bool paidmagic = false;
13497
6/8
✓ Branch 0 taken 7698 times.
✓ Branch 1 taken 1199 times.
✓ Branch 2 taken 489 times.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 489 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1199 times.
8897 if(btnwpn==itype_wand && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_wand : false) : current_item(itype_wand)))
13498 {
13499
2/2
✓ Branch 0 taken 489 times.
✓ Branch 1 taken 710 times.
1199 attackid=directWpn>-1 ? directWpn : current_item_id(itype_wand);
13500 1199 no_jinx = checkitem_jinx(attackid);
13501
3/8
✓ Branch 0 taken 1199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1199 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1199 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1199 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
13502 {
13503
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1199 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1199 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_WAND_COST)){
13504 paymagiccost(attackid,true);
13505 misc_internal_hero_flags |= LF_PAID_WAND_COST;
13506 }
13507 1199 SetAttack();
13508 1199 attack=wWand;
13509 1199 attackclk=0;
13510 1199 }
13511 else
13512 {
13513 item_error();
13514 }
13515 1199 }
13516
4/6
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 7613 times.
✓ Branch 2 taken 85 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 85 times.
7783 else if((btnwpn==itype_hammer)&&!((action==attacking||action==sideswimattacking) && attack==wHammer)
13517
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 85 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
85 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_hammer : false) : current_item(itype_hammer)))
13518 {
13519 85 no_jinx = checkitem_jinx(dowpn);
13520
3/6
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 85 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 85 times.
85 if(!(no_jinx && checkmagiccost(dowpn) && checkbunny(dowpn)))
13521 {
13522 item_error();
13523 }
13524 else
13525 {
13526 85 paymagiccost(dowpn);
13527 85 paidmagic = true;
13528 85 SetAttack();
13529 85 attack=wHammer;
13530
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 attackid=directWpn>-1 ? directWpn : current_item_id(itype_hammer);
13531 85 attackclk=0;
13532 }
13533 85 }
13534
4/6
✓ Branch 0 taken 982 times.
✓ Branch 1 taken 6631 times.
✓ Branch 2 taken 982 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 982 times.
8595 else if((btnwpn==itype_candle)&&!((action==attacking||action==sideswimattacking) && attack==wFire)
13535
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 982 times.
✓ Branch 2 taken 814 times.
✓ Branch 3 taken 168 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
982 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_candle : false) : current_item(itype_candle)))
13536 {
13537 //checkbunny handled where magic cost is paid
13538
2/2
✓ Branch 0 taken 814 times.
✓ Branch 1 taken 168 times.
982 attackid=directWpn>-1 ? directWpn : current_item_id(itype_candle);
13539 982 no_jinx = checkitem_jinx(attackid);
13540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 982 times.
982 if(no_jinx)
13541 {
13542 982 SetAttack();
13543 982 attack=wFire;
13544 982 attackclk=0;
13545 982 }
13546 982 }
13547
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6631 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6631 else if((btnwpn==itype_cbyrna)&&!((action==attacking||action==sideswimattacking) && attack==wCByrna)
13548 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_cbyrna : false) : current_item(itype_cbyrna)))
13549 {
13550 attackid=directWpn>-1 ? directWpn : current_item_id(itype_cbyrna);
13551 no_jinx = checkitem_jinx(attackid);
13552 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
13553 {
13554 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_CBYRNA_COST)){
13555 paymagiccost(attackid,true);
13556 misc_internal_hero_flags |= LF_PAID_CBYRNA_COST;
13557 }
13558 SetAttack();
13559 attack=wCByrna;
13560 attackclk=0;
13561 }
13562 else
13563 {
13564 item_error();
13565 }
13566 }
13567
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6631 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6631 else if((btnwpn==itype_bugnet)&&!((action==attacking||action==sideswimattacking) && attack==wBugNet)
13568 && (directWpn>-1 ? (!item_disabled(directWpn) && itemsbuf[directWpn].family==itype_bugnet) : current_item(itype_bugnet)))
13569 {
13570 attackid = directWpn>-1 ? directWpn : current_item_id(itype_bugnet);
13571 no_jinx = checkitem_jinx(attackid);
13572 if(no_jinx && checkbunny(attackid) && checkmagiccost(attackid))
13573 {
13574 paymagiccost(attackid);
13575 SetAttack();
13576 attack = wBugNet;
13577 attackclk = 0;
13578 sfx(itemsbuf[attackid].usesound);
13579 }
13580 else
13581 {
13582 item_error();
13583 }
13584 }
13585 else
13586 {
13587
2/2
✓ Branch 0 taken 6617 times.
✓ Branch 1 taken 14 times.
6631 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
13588 6631 no_jinx = checkitem_jinx(itmid);
13589
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 6617 times.
6631 if(no_jinx)
13590 {
13591 6617 paidmagic = startwpn(itmid);
13592
13593
2/2
✓ Branch 0 taken 5992 times.
✓ Branch 1 taken 625 times.
6617 if(paidmagic)
13594 {
13595
5/10
✓ Branch 0 taken 5992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5992 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5992 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5992 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 5992 times.
5992 if(action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning)
13596 {
13597 ;
13598 }
13599 else
13600 {
13601 5992 SetAttack();
13602 5992 attackclk=0;
13603 5992 attack=none;
13604
13605
2/2
✓ Branch 0 taken 869 times.
✓ Branch 1 taken 5123 times.
5992 if(btnwpn==itype_brang)
13606 {
13607 5123 attack=wBrang;
13608 5123 }
13609 }
13610 5992 }
13611 else
13612 {
13613 // Weapon not started: directWpn should be reset to prev. value.
13614 625 directWpn = olddirectwpn;
13615 }
13616 6617 }
13617 }
13618
13619
7/12
✓ Branch 0 taken 8897 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8883 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 112 times.
✓ Branch 5 taken 8771 times.
✓ Branch 6 taken 112 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 112 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8897 if(dowpn>-1 && no_jinx && itemsbuf[dowpn].script!=0 && !did_scriptb && !(item_doscript[dowpn] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
13620 {
13621
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
112 if(!((paidmagic || checkmagiccost(dowpn)) && checkbunny(dowpn)))
13622 {
13623 item_error();
13624 }
13625 else
13626 {
13627 // Only charge for magic if item's magic cost wasn't already charged
13628 // for the item's main use.
13629
3/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 109 times.
112 if(!paidmagic && attack!=wWand)
13630 109 paymagiccost(dowpn);
13631 //clear the item script stack for a new script
13632 //itemScriptData[(dowpn & 0xFFF)].Clear();
13633 112 ri = &(itemScriptData[dowpn]);
13634
2/2
✓ Branch 0 taken 114688 times.
✓ Branch 1 taken 112 times.
114800 for ( int32_t q = 0; q < 1024; q++ ) item_stack[dowpn][q] = 0xFFFF;
13635 112 ri->Clear();
13636 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(dowpn & 0xFFF)][q] = 0;
13637 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn & 0xFFF);
13638 112 item_doscript[dowpn] = 1;
13639 112 itemscriptInitialised[dowpn] = 0;
13640 112 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn);
13641 112 did_scriptb=true;
13642 }
13643 112 }
13644
13645
7/12
✓ Branch 0 taken 8883 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 8883 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8883 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8883 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8883 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 8883 times.
8897 if(no_jinx && (action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning))
13646 {
13647 return;
13648 }
13649
2/2
✓ Branch 0 taken 8883 times.
✓ Branch 1 taken 14 times.
8897 if(!no_jinx)
13650 14 did_scriptb = false;
13651 8897 }
13652 else
13653 {
13654 3249180 did_scriptb=false;
13655 }
13656
13657
5/6
✓ Branch 0 taken 2752134 times.
✓ Branch 1 taken 505943 times.
✓ Branch 2 taken 2712148 times.
✓ Branch 3 taken 39986 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2712148 times.
3258077 if(attackclk || action==attacking || action==sideswimattacking)
13658 {
13659
13660
4/8
✓ Branch 0 taken 39986 times.
✓ Branch 1 taken 505943 times.
✓ Branch 2 taken 39986 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 39986 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
545929 if((attackclk==0) && action!=sideswimattacking && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
13661 {
13662 if((xoff==0)||diagonalMovement)
13663 {
13664 if(DrunkUp()) dir=up;
13665 if(DrunkDown()) dir=down;
13666 }
13667
13668 if((yoff==0)||diagonalMovement)
13669 {
13670 if(DrunkLeft()) dir=left;
13671 if(DrunkRight()) dir=right;
13672 }
13673 }
13674
13675 545929 bool attacked = doattack();
13676
13677 // This section below interferes with script-setting Hero->Dir, so it comes after doattack
13678
10/12
✓ Branch 0 taken 544330 times.
✓ Branch 1 taken 1599 times.
✓ Branch 2 taken 386307 times.
✓ Branch 3 taken 158023 times.
✓ Branch 4 taken 73386 times.
✓ Branch 5 taken 312921 times.
✓ Branch 6 taken 71710 times.
✓ Branch 7 taken 1676 times.
✓ Branch 8 taken 71710 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 71710 times.
545929 if(!inlikelike && attackclk>4 && (attackclk&3)==0 && charging==0 && spins==0 && action!=sideswimattacking)
13679 {
13680
4/4
✓ Branch 0 taken 31044 times.
✓ Branch 1 taken 40666 times.
✓ Branch 2 taken 2753 times.
✓ Branch 3 taken 28291 times.
71710 if((xoff==0)||diagonalMovement)
13681 {
13682
2/2
✓ Branch 0 taken 39732 times.
✓ Branch 1 taken 3687 times.
43419 if(DrunkUp()) dir=up;
13683
13684
2/2
✓ Branch 0 taken 39431 times.
✓ Branch 1 taken 3988 times.
43419 if(DrunkDown()) dir=down;
13685 43419 }
13686
13687
4/4
✓ Branch 0 taken 22723 times.
✓ Branch 1 taken 48987 times.
✓ Branch 2 taken 2638 times.
✓ Branch 3 taken 20085 times.
71710 if((yoff==0)||diagonalMovement)
13688 {
13689
2/2
✓ Branch 0 taken 46381 times.
✓ Branch 1 taken 5244 times.
51625 if(DrunkLeft()) dir=left;
13690
13691
2/2
✓ Branch 0 taken 46664 times.
✓ Branch 1 taken 4961 times.
51625 if(DrunkRight()) dir=right;
13692 51625 }
13693 71710 }
13694
13695
9/10
✓ Branch 0 taken 508007 times.
✓ Branch 1 taken 37922 times.
✓ Branch 2 taken 506086 times.
✓ Branch 3 taken 1921 times.
✓ Branch 4 taken 505651 times.
✓ Branch 5 taken 435 times.
✓ Branch 6 taken 505479 times.
✓ Branch 7 taken 172 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 505479 times.
545929 if(attacked && (charging==0 && spins<=5) && jumping<1 && action!=sideswimattacking)
13696 {
13697 505479 return;
13698 }
13699
2/2
✓ Branch 0 taken 2528 times.
✓ Branch 1 taken 37922 times.
40450 else if(!(attacked))
13700 {
13701 // Spin attack - change direction
13702
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 37674 times.
37922 if(spins>1)
13703 {
13704 248 spins--;
13705
13706
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 45 times.
248 if(spins%5==0)
13707 45 sfx(itemsbuf[current_item_id(spins >5 ? itype_spinscroll2 : itype_spinscroll)].usesound,pan(x.getInt()));
13708
13709 248 attackclk=1;
13710
13711
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 62 times.
248 switch(dir)
13712 {
13713 case up:
13714 62 dir=left;
13715 62 break;
13716
13717 case right:
13718 62 dir=up;
13719 62 break;
13720
13721 case down:
13722 62 dir=right;
13723 62 break;
13724
13725 case left:
13726 62 dir=down;
13727 62 break;
13728 }
13729
13730 248 return;
13731 }
13732 else
13733 {
13734 37674 spins=0;
13735 }
13736
13737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37674 times.
37674 if (IsSideSwim()) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
13738 37674 else {action=none; FFCore.setHeroAction(none);}
13739 37674 attackclk=0;
13740 37674 charging=0;
13741 37674 }
13742 40202 }
13743
13744
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2752347 times.
2752350 if(pitslide()) //Check pit's 'pull'. If true, then Hero cannot fight the pull.
13745 3 return;
13746
13747
2/2
✓ Branch 0 taken 981443 times.
✓ Branch 1 taken 1770904 times.
2752347 if(action==walking) //still walking
13748 {
13749
9/10
✓ Branch 0 taken 1326674 times.
✓ Branch 1 taken 444230 times.
✓ Branch 2 taken 977896 times.
✓ Branch 3 taken 348778 times.
✓ Branch 4 taken 515922 times.
✓ Branch 5 taken 461974 times.
✓ Branch 6 taken 21179 times.
✓ Branch 7 taken 494743 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 21179 times.
1770904 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
13750 {
13751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21179 times.
21179 if(attackclk>0) SetAttack();
13752 21179 else {action = none; FFCore.setHeroAction(none);}
13753 21179 hero_count=-1;
13754 21179 return;
13755 }
13756
13757 1749725 autostep=false;
13758
13759
3/4
✓ Branch 0 taken 1608398 times.
✓ Branch 1 taken 141327 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1608398 times.
1749725 if(!(diagonalMovement || NO_GRIDLOCK))
13760 {
13761
2/4
✓ Branch 0 taken 1608398 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1608398 times.
1608398 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
13762 {
13763 if(dir==up&&yoff)
13764 {
13765 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
13766 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
13767 execute(info);
13768
13769 if(!info.isUnwalkable())
13770 {
13771 move(up);
13772 }
13773 else
13774 {
13775 action=none; FFCore.setHeroAction(none);
13776 }
13777
13778 return;
13779 }
13780
13781 if(dir==down&&yoff)
13782 {
13783 info = walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
13784 info = info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7]));
13785 execute(info);
13786
13787 if(!info.isUnwalkable())
13788 {
13789 move(down);
13790 }
13791 else
13792 {
13793 action=none; FFCore.setHeroAction(none);
13794 }
13795
13796 return;
13797 }
13798
13799 if(dir==left&&xoff)
13800 {
13801 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) || walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
13802 execute(info);
13803
13804 if(!info.isUnwalkable())
13805 {
13806 move(left);
13807 }
13808 else
13809 {
13810 action=none; FFCore.setHeroAction(none);
13811 }
13812
13813 return;
13814 }
13815
13816 if(dir==right&&xoff)
13817 {
13818 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
13819 execute(info);
13820
13821 if(!info.isUnwalkable())
13822 {
13823 move(right);
13824 }
13825 else
13826 {
13827 action=none; FFCore.setHeroAction(none);
13828 }
13829
13830 return;
13831 }
13832 }
13833 else
13834 {
13835
4/4
✓ Branch 0 taken 382498 times.
✓ Branch 1 taken 1225900 times.
✓ Branch 2 taken 62730 times.
✓ Branch 3 taken 319768 times.
1608398 if(dir==up&&yoff)
13836 {
13837 319768 while(true)
13838 {
13839 319768 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
13840 319768 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
13841 319768 execute(info);
13842
13843
2/2
✓ Branch 0 taken 1011 times.
✓ Branch 1 taken 318757 times.
319768 if(!info.isUnwalkable())
13844 {
13845 318757 hero_newstep = temp_step;
13846 318757 x = temp_x;
13847 318757 y = temp_y;
13848 318757 move(up);
13849 318757 return;
13850 }
13851 //Could not move, try moving less
13852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1011 times.
1011 if(temp_y != int32_t(temp_y))
13853 {
13854 temp_y = floor((double)temp_y);
13855 continue;
13856 }
13857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1011 times.
1011 else if(temp_step > 1)
13858 {
13859 if(temp_step != int32_t(temp_step)) //floor
13860 temp_step = floor((double)temp_step);
13861 else --temp_step;
13862 continue;
13863 }
13864 else //Can't move less, stop moving
13865 {
13866 1011 action=none; FFCore.setHeroAction(none);
13867 }
13868 1011 return;
13869 }
13870 }
13871
13872
4/4
✓ Branch 0 taken 300651 times.
✓ Branch 1 taken 987979 times.
✓ Branch 2 taken 49648 times.
✓ Branch 3 taken 251003 times.
1288630 if(dir==down&&yoff)
13873 {
13874 251003 while(true)
13875 {
13876 251007 info = walkflag(temp_x,temp_y+15+temp_step,2,down);
13877 251007 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
13878 251007 execute(info);
13879
13880
2/2
✓ Branch 0 taken 830 times.
✓ Branch 1 taken 250177 times.
251007 if(!info.isUnwalkable())
13881 {
13882 250177 hero_newstep = temp_step;
13883 250177 x = temp_x;
13884 250177 y = temp_y;
13885 250177 move(down);
13886 250177 return;
13887 }
13888 //Could not move, try moving less
13889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 830 times.
830 if(temp_y != int32_t(temp_y))
13890 {
13891 temp_y = floor((double)temp_y);
13892 continue;
13893 }
13894
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 826 times.
830 else if(temp_step > 1)
13895 {
13896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(temp_step != int32_t(temp_step)) //floor
13897 4 temp_step = floor((double)temp_step);
13898 else --temp_step;
13899 4 continue;
13900 }
13901 else //Can't move less, stop moving
13902 {
13903 826 action=none; FFCore.setHeroAction(none);
13904 }
13905 826 return;
13906 }
13907 }
13908
13909
4/4
✓ Branch 0 taken 447026 times.
✓ Branch 1 taken 590601 times.
✓ Branch 2 taken 74975 times.
✓ Branch 3 taken 372051 times.
1037627 if(dir==left&&xoff)
13910 {
13911 372051 while(true)
13912 {
13913 372051 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) || walkflag(temp_x-temp_step,temp_y+8,1,left);
13914 372051 execute(info);
13915
13916
2/2
✓ Branch 0 taken 769 times.
✓ Branch 1 taken 371282 times.
372051 if(!info.isUnwalkable())
13917 {
13918 371282 hero_newstep = temp_step;
13919 371282 x = temp_x;
13920 371282 y = temp_y;
13921 371282 move(left);
13922 371282 return;
13923 }
13924 //Could not move, try moving less
13925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 769 times.
769 if(temp_x != int32_t(temp_x))
13926 {
13927 temp_x = floor((double)temp_x);
13928 continue;
13929 }
13930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 769 times.
769 else if(temp_step > 1)
13931 {
13932 if(temp_step != int32_t(temp_step)) //floor
13933 temp_step = floor((double)temp_step);
13934 else --temp_step;
13935 continue;
13936 }
13937 else //Can't move less, stop moving
13938 {
13939 769 action=none; FFCore.setHeroAction(none);
13940 }
13941 769 return;
13942 }
13943 }
13944
13945
4/4
✓ Branch 0 taken 478223 times.
✓ Branch 1 taken 187353 times.
✓ Branch 2 taken 79960 times.
✓ Branch 3 taken 398263 times.
665576 if(dir==right&&xoff)
13946 {
13947 398263 while(true)
13948 {
13949 398269 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) || walkflag(temp_x+15+temp_step,temp_y+8,1,right);
13950 398269 execute(info);
13951
13952
2/2
✓ Branch 0 taken 879 times.
✓ Branch 1 taken 397390 times.
398269 if(!info.isUnwalkable())
13953 {
13954 397390 hero_newstep = temp_step;
13955 397390 x = temp_x;
13956 397390 y = temp_y;
13957 397390 move(right);
13958 397390 return;
13959 }
13960 //Could not move, try moving less
13961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 879 times.
879 if(temp_x != int32_t(temp_x))
13962 {
13963 temp_x = floor((double)temp_x);
13964 continue;
13965 }
13966
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 873 times.
879 else if(temp_step > 1)
13967 {
13968
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(temp_step != int32_t(temp_step)) //floor
13969 6 temp_step = floor((double)temp_step);
13970 else --temp_step;
13971 6 continue;
13972 }
13973 else //Can't move less, stop moving
13974 {
13975 873 action=none; FFCore.setHeroAction(none);
13976 }
13977 873 return;
13978 }
13979 }
13980 }
13981 267313 }
13982
13983 408640 } // endif (action==walking)
13984
13985
16/24
✓ Branch 0 taken 1369054 times.
✓ Branch 1 taken 21029 times.
✓ Branch 2 taken 1369054 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1369054 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1369054 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1369054 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1369054 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1369054 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1369054 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1369054 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1367133 times.
✓ Branch 19 taken 1921 times.
✓ Branch 20 taken 1366698 times.
✓ Branch 21 taken 435 times.
✓ Branch 22 taken 12935 times.
✓ Branch 23 taken 1353763 times.
1390083 if((action!=swimming)&&(action!=sideswimming)&&(action !=sideswimhit)&&(action !=sideswimattacking)&&(action!=casting)&&(action!=sideswimcasting)&&(action!=drowning)&&(action!=sidedrowning)&&(action!=lavadrowning) && charging==0 && spins==0 && jumping<1)
13986 {
13987 1353763 action=none; FFCore.setHeroAction(none);
13988 1353763 }
13989
13990
2/2
✓ Branch 0 taken 238819 times.
✓ Branch 1 taken 1151264 times.
1390083 if(diagonalMovement)
13991 {
13992
5/5
✓ Branch 0 taken 75880 times.
✓ Branch 1 taken 31893 times.
✓ Branch 2 taken 27989 times.
✓ Branch 3 taken 49243 times.
✓ Branch 4 taken 53814 times.
238819 switch(holddir)
13993 {
13994 case up:
13995
2/2
✓ Branch 0 taken 30734 times.
✓ Branch 1 taken 1159 times.
31893 if(!Up())
13996 {
13997 1159 holddir=-1;
13998 1159 }
13999
14000 31893 break;
14001
14002 case down:
14003
2/2
✓ Branch 0 taken 26835 times.
✓ Branch 1 taken 1154 times.
27989 if(!Down())
14004 {
14005 1154 holddir=-1;
14006 1154 }
14007
14008 27989 break;
14009
14010 case left:
14011
2/2
✓ Branch 0 taken 47637 times.
✓ Branch 1 taken 1606 times.
49243 if(!Left())
14012 {
14013 1606 holddir=-1;
14014 1606 }
14015
14016 49243 break;
14017
14018 case right:
14019
2/2
✓ Branch 0 taken 52198 times.
✓ Branch 1 taken 1616 times.
53814 if(!Right())
14020 {
14021 1616 holddir=-1;
14022 1616 }
14023
14024 53814 break;
14025
14026 default:
14027 75880 break;
14028 } //end switch
14029
14030
3/4
✓ Branch 0 taken 109648 times.
✓ Branch 1 taken 129171 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 109648 times.
238819 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim()) //!DIRECTION SET
14031 {
14032 129171 walkable = false;
14033
6/6
✓ Branch 0 taken 22760 times.
✓ Branch 1 taken 106411 times.
✓ Branch 2 taken 22082 times.
✓ Branch 3 taken 678 times.
✓ Branch 4 taken 6363 times.
✓ Branch 5 taken 15719 times.
129171 if(DrunkUp()&&(holddir==-1||holddir==up))
14034 {
14035
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 16397 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
16397 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14036 {
14037 }
14038 else
14039 {
14040
4/10
✓ Branch 0 taken 16397 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16397 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16397 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 16397 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
16397 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
14041 {
14042 16397 dir=up;
14043 16397 }
14044
14045 16397 holddir=up;
14046
14047
4/4
✓ Branch 0 taken 2060 times.
✓ Branch 1 taken 14337 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 2055 times.
16397 if(DrunkRight()&&shiftdir!=left)
14048 {
14049 2055 shiftdir=right;
14050
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2055 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2055 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
14051
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2055 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2055 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
14052 2055 }
14053
4/4
✓ Branch 0 taken 2050 times.
✓ Branch 1 taken 12292 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2048 times.
14342 else if(DrunkLeft()&&shiftdir!=right)
14054 {
14055 2048 shiftdir=left;
14056
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2048 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
14057
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2048 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
14058 2048 }
14059 else
14060 {
14061 12294 shiftdir=-1;
14062 }
14063
14064 //walkable if Ladder can be placed or is already placed vertically
14065
9/20
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 16203 times.
✓ Branch 2 taken 194 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 194 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 55 times.
✓ Branch 13 taken 139 times.
✓ Branch 14 taken 55 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 55 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 55 times.
16397 if(isSideViewHero() && !toogam && (!get_bit(quest_rules, qr_OLD_LADDER_ITEM_SIDEVIEW) || !(can_deploy_ladder() || (ladderx && laddery && ladderdir==up))) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14066 {
14067 55 walkable=false;
14068 55 }
14069 else
14070 {
14071 16342 do
14072 {
14073 18976 info = walkflag(x,(bigHitbox?0:8)+(y-hero_newstep),2,up);
14074
14075 18976 info = info || walkflag(x+15,(bigHitbox?0:8)+(y-hero_newstep),1,up);
14076 18976 info = info || walkflagMBlock(x+15, (bigHitbox?0:8)+(y-hero_newstep));
14077
14078 18976 execute(info);
14079
14080
2/2
✓ Branch 0 taken 5093 times.
✓ Branch 1 taken 13883 times.
18976 if(info.isUnwalkable())
14081 {
14082
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 4918 times.
5093 if(y != y.getInt())
14083 {
14084 175 y.doRound();
14085 175 }
14086
2/2
✓ Branch 0 taken 2459 times.
✓ Branch 1 taken 2459 times.
4918 else if(hero_newstep > 1)
14087 {
14088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2459 times.
2459 if(hero_newstep != int32_t(hero_newstep)) //floor
14089 2459 hero_newstep = floor((double)hero_newstep);
14090 else --hero_newstep;
14091 2459 }
14092 else
14093 2459 break;
14094 2634 }
14095 13883 else walkable = true;
14096
2/2
✓ Branch 0 taken 2634 times.
✓ Branch 1 taken 13883 times.
16517 }
14097 16517 while(!walkable);
14098 }
14099
14100 16397 int32_t s=shiftdir;
14101
14102
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16397 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16397 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
14103 {
14104 shiftdir=-1;
14105 }
14106 else
14107 {
14108
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 14349 times.
16397 if(s==left)
14109 {
14110 2048 do
14111 {
14112 2452 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
14113
14114 2452 execute(info);
14115
14116
2/2
✓ Branch 0 taken 775 times.
✓ Branch 1 taken 1677 times.
2452 if(info.isUnwalkable())
14117 {
14118
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 742 times.
775 if(x != x.getInt())
14119 {
14120 33 x.doRound();
14121 33 }
14122
2/2
✓ Branch 0 taken 371 times.
✓ Branch 1 taken 371 times.
742 else if(hero_newstep_diag > 1)
14123 {
14124
1/2
✓ Branch 0 taken 371 times.
✗ Branch 1 not taken.
371 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14125 371 hero_newstep_diag.doFloor();
14126 else --hero_newstep_diag;
14127 371 }
14128 else
14129 371 shiftdir = -1;
14130 775 }
14131
2/2
✓ Branch 0 taken 1418 times.
✓ Branch 1 taken 259 times.
1677 else if(walkable)
14132 {
14133 1418 do
14134 {
14135 1422 info = walkflag(x-hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,left);
14136 1422 execute(info);
14137
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1415 times.
1422 if(info.isUnwalkable())
14138 {
14139
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6 times.
7 if(x != x.getInt())
14140 {
14141 1 x.doRound();
14142 1 }
14143
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 else if(hero_newstep_diag > 1)
14144 {
14145
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14146 3 hero_newstep_diag.doFloor();
14147 else --hero_newstep_diag;
14148 3 }
14149 else
14150 3 shiftdir = -1;
14151 7 }
14152 1415 else break;
14153
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 }
14154 7 while(shiftdir != -1);
14155 1418 break;
14156 }
14157 259 else break;
14158
2/2
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 371 times.
775 }
14159 775 while(shiftdir != -1);
14160 2048 }
14161
2/2
✓ Branch 0 taken 12294 times.
✓ Branch 1 taken 2055 times.
14349 else if(s==right)
14162 {
14163 2055 do
14164 {
14165 2373 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
14166
14167 2373 execute(info);
14168
14169
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 1772 times.
2373 if(info.isUnwalkable())
14170 {
14171
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 566 times.
601 if(x != x.getInt())
14172 {
14173 35 x.doRound();
14174 35 }
14175
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 283 times.
566 else if(hero_newstep_diag > 1)
14176 {
14177
1/2
✓ Branch 0 taken 283 times.
✗ Branch 1 not taken.
283 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14178 283 hero_newstep_diag.doFloor();
14179 else --hero_newstep_diag;
14180 283 }
14181 else
14182 283 shiftdir = -1;
14183 601 }
14184
2/2
✓ Branch 0 taken 1442 times.
✓ Branch 1 taken 330 times.
1772 else if(walkable)
14185 {
14186 1442 do
14187 {
14188 1448 info = walkflag(x+15+hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,right);
14189 1448 execute(info);
14190
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1437 times.
1448 if(info.isUnwalkable())
14191 {
14192
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if(x != x.getInt())
14193 {
14194 1 x.doRound();
14195 1 }
14196
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
10 else if(hero_newstep_diag > 1)
14197 {
14198
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14199 5 hero_newstep_diag.doFloor();
14200 else --hero_newstep_diag;
14201 5 }
14202 else
14203 5 shiftdir = -1;
14204 11 }
14205 1437 else break;
14206
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5 times.
11 }
14207 11 while(shiftdir != -1);
14208 1442 break;
14209 }
14210 330 else break;
14211
2/2
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 283 times.
601 }
14212 601 while(shiftdir != -1);
14213 2055 }
14214 }
14215
14216 16397 move(up);
14217 16397 shiftdir=s;
14218
14219
2/2
✓ Branch 0 taken 13883 times.
✓ Branch 1 taken 2514 times.
16397 if(!walkable)
14220 {
14221
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 1854 times.
2514 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14222 {
14223 1854 x = x.getInt();
14224 1854 y = y.getInt();
14225
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1854 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1854 times.
✓ Branch 4 taken 1576 times.
✓ Branch 5 taken 278 times.
✓ Branch 6 taken 111 times.
✓ Branch 7 taken 1743 times.
2132 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14226
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 278 times.
✓ Branch 4 taken 115 times.
✓ Branch 5 taken 163 times.
278 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14227
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 163 times.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
14228 {
14229
5/8
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 111 times.
111 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
14230 111 sprite::move((zfix)-1,(zfix)0);
14231 111 }
14232 else
14233 {
14234
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1743 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1743 times.
✓ Branch 4 taken 167 times.
✓ Branch 5 taken 1576 times.
✓ Branch 6 taken 129 times.
✓ Branch 7 taken 1614 times.
3319 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14235
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
✓ Branch 2 taken 1576 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1447 times.
✓ Branch 5 taken 129 times.
1576 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14236
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
129 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
14237 {
14238
4/8
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 129 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 129 times.
129 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
14239 129 sprite::move((zfix)1,(zfix)0);
14240 129 }
14241 else
14242 {
14243 1614 pushing=push+1;
14244 }
14245 }
14246 1854 }
14247 else
14248 {
14249 660 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14250 }
14251 2514 }
14252
14253 16397 return;
14254 }
14255 }
14256
14257
6/6
✓ Branch 0 taken 21942 times.
✓ Branch 1 taken 90832 times.
✓ Branch 2 taken 21182 times.
✓ Branch 3 taken 760 times.
✓ Branch 4 taken 15825 times.
✓ Branch 5 taken 5357 times.
112774 if(DrunkDown()&&(holddir==-1||holddir==down))
14258 {
14259
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 16585 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
16585 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14260 {
14261 }
14262 else
14263 {
14264
4/10
✓ Branch 0 taken 16585 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16585 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16585 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 16585 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
16585 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
14265 {
14266 16585 dir=down;
14267 16585 }
14268
14269 16585 holddir=down;
14270
14271
3/4
✓ Branch 0 taken 2833 times.
✓ Branch 1 taken 13752 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2833 times.
16585 if(DrunkRight()&&shiftdir!=left)
14272 {
14273 2833 shiftdir=right;
14274
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2833 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2833 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
14275
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2833 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2833 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
14276 2833 }
14277
4/4
✓ Branch 0 taken 2602 times.
✓ Branch 1 taken 11150 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2601 times.
13752 else if(DrunkLeft()&&shiftdir!=right)
14278 {
14279 2601 shiftdir=left;
14280
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2601 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2601 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
14281
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2601 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2601 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
14282 2601 }
14283 else
14284 {
14285 11151 shiftdir=-1;
14286 }
14287
14288 //bool walkable;
14289
7/12
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 15925 times.
✓ Branch 2 taken 660 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 660 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 660 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 660 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 660 times.
16585 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14290 {
14291 660 walkable=false;
14292 660 }
14293 else
14294 {
14295 15925 do
14296 {
14297 17947 info = walkflag(x,15+(y+hero_newstep),2,down);
14298
14299
2/2
✓ Branch 0 taken 10473 times.
✓ Branch 1 taken 7474 times.
17947 if(x.getFloor() & 7)
14300 10473 info = info || walkflag(x+15,15+(y+hero_newstep),1,down);
14301 else
14302 7474 info = info || walkflagMBlock(x+15, 15+(y+hero_newstep));
14303
14304 17947 execute(info);
14305
14306
2/2
✓ Branch 0 taken 3831 times.
✓ Branch 1 taken 14116 times.
17947 if(info.isUnwalkable())
14307 {
14308
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 3621 times.
3831 if(y != y.getInt())
14309 {
14310 210 y.doRound();
14311 210 }
14312
2/2
✓ Branch 0 taken 1812 times.
✓ Branch 1 taken 1809 times.
3621 else if(hero_newstep > 1)
14313 {
14314
1/2
✓ Branch 0 taken 1812 times.
✗ Branch 1 not taken.
1812 if(hero_newstep != int32_t(hero_newstep)) //floor
14315 1812 hero_newstep = floor((double)hero_newstep);
14316 else --hero_newstep;
14317 1812 }
14318 else
14319 1809 break;
14320 2022 }
14321 14116 else walkable = true;
14322
2/2
✓ Branch 0 taken 2022 times.
✓ Branch 1 taken 14116 times.
16138 }
14323 16138 while(!walkable);
14324 }
14325
14326 16585 int32_t s=shiftdir;
14327
14328
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16585 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16585 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
14329 {
14330 shiftdir=-1;
14331 }
14332 else
14333 {
14334
2/2
✓ Branch 0 taken 2601 times.
✓ Branch 1 taken 13984 times.
16585 if(s==left)
14335 {
14336 2601 do
14337 {
14338 2995 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
14339
14340 2995 execute(info);
14341
14342
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 2255 times.
2995 if(info.isUnwalkable())
14343 {
14344
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 692 times.
740 if(x != x.getInt())
14345 {
14346 48 x.doRound();
14347 48 }
14348
2/2
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 346 times.
692 else if(hero_newstep_diag > 1)
14349 {
14350
1/2
✓ Branch 0 taken 346 times.
✗ Branch 1 not taken.
346 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14351 346 hero_newstep_diag.doFloor();
14352 else --hero_newstep_diag;
14353 346 }
14354 else
14355 346 shiftdir = -1;
14356 740 }
14357
2/2
✓ Branch 0 taken 1789 times.
✓ Branch 1 taken 466 times.
2255 else if(walkable)
14358 {
14359 1789 do
14360 {
14361 1796 info = walkflag(x-hero_newstep_diag,15+(y+hero_newstep),1,left);
14362 1796 execute(info);
14363
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1786 times.
1796 if(info.isUnwalkable())
14364 {
14365
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 6 times.
10 if(x != x.getInt())
14366 {
14367 4 x.doRound();
14368 4 }
14369
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 else if(hero_newstep_diag > 1)
14370 {
14371
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14372 3 hero_newstep_diag.doFloor();
14373 else --hero_newstep_diag;
14374 3 }
14375 else
14376 3 shiftdir = -1;
14377 10 }
14378 1786 else break;
14379
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3 times.
10 }
14380 10 while(shiftdir != -1);
14381 1789 break;
14382 }
14383 466 else break;
14384
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 346 times.
740 }
14385 740 while(shiftdir != -1);
14386 2601 }
14387
2/2
✓ Branch 0 taken 11151 times.
✓ Branch 1 taken 2833 times.
13984 else if(s==right)
14388 {
14389 2833 do
14390 {
14391 3166 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
14392
14393 3166 execute(info);
14394
14395
2/2
✓ Branch 0 taken 642 times.
✓ Branch 1 taken 2524 times.
3166 if(info.isUnwalkable())
14396 {
14397
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 618 times.
642 if(x != x.getInt())
14398 {
14399 24 x.doRound();
14400 24 }
14401
2/2
✓ Branch 0 taken 309 times.
✓ Branch 1 taken 309 times.
618 else if(hero_newstep_diag > 1)
14402 {
14403
1/2
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
309 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14404 309 hero_newstep_diag.doFloor();
14405 else --hero_newstep_diag;
14406 309 }
14407 else
14408 309 shiftdir = -1;
14409 642 }
14410
2/2
✓ Branch 0 taken 1902 times.
✓ Branch 1 taken 622 times.
2524 else if(walkable)
14411 {
14412 1902 do
14413 {
14414 1908 info = walkflag(x+15+hero_newstep_diag,15+(y+hero_newstep),1,right);
14415 1908 execute(info);
14416
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1897 times.
1908 if(info.isUnwalkable())
14417 {
14418
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if(x != x.getInt())
14419 {
14420 1 x.doRound();
14421 1 }
14422
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
10 else if(hero_newstep_diag > 1)
14423 {
14424
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14425 5 hero_newstep_diag.doFloor();
14426 else --hero_newstep_diag;
14427 5 }
14428 else
14429 5 shiftdir = -1;
14430 11 }
14431 1897 else break;
14432
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5 times.
11 }
14433 11 while(shiftdir != -1);
14434 1902 break;
14435 }
14436 622 else break;
14437
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 309 times.
642 }
14438 642 while(shiftdir != -1);
14439 2833 }
14440 }
14441
14442 16585 move(down);
14443 16585 shiftdir=s;
14444
14445
2/2
✓ Branch 0 taken 14116 times.
✓ Branch 1 taken 2469 times.
16585 if(!walkable)
14446 {
14447
2/2
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 1354 times.
2469 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14448 {
14449 1354 x = x.getInt();
14450 1354 y = y.getInt();
14451
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1354 times.
✓ Branch 2 taken 1354 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 866 times.
✓ Branch 5 taken 488 times.
✓ Branch 6 taken 133 times.
✓ Branch 7 taken 1221 times.
1842 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
14452
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 488 times.
✓ Branch 2 taken 488 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 426 times.
488 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
14453
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 426 times.
✗ Branch 3 not taken.
426 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
14454 {
14455
4/8
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 133 times.
133 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
14456 133 sprite::move((zfix)-1,(zfix)0);
14457 133 }
14458
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1221 times.
✓ Branch 2 taken 1221 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 355 times.
✓ Branch 5 taken 866 times.
✓ Branch 6 taken 151 times.
✓ Branch 7 taken 1070 times.
2087 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
14459
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 866 times.
✓ Branch 2 taken 866 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 715 times.
✓ Branch 5 taken 151 times.
866 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
14460
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 151 times.
151 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
14461 {
14462
4/8
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 151 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 151 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 151 times.
151 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
14463 151 sprite::move((zfix)1,(zfix)0);
14464 151 }
14465 else
14466 {
14467 1070 pushing=push+1;
14468 }
14469 1354 }
14470 else
14471 {
14472 1115 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14473 }
14474 2469 }
14475
14476 16585 return;
14477 }
14478 }
14479
14480
6/6
✓ Branch 0 taken 23618 times.
✓ Branch 1 taken 72571 times.
✓ Branch 2 taken 22755 times.
✓ Branch 3 taken 863 times.
✓ Branch 4 taken 22748 times.
✓ Branch 5 taken 7 times.
96189 if(DrunkLeft()&&(holddir==-1||holddir==left))
14481 {
14482
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 23611 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
23611 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14483 {
14484 }
14485 else
14486 {
14487
3/6
✓ Branch 0 taken 23611 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23611 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23611 times.
23611 if(charging==0 && spins==0 && action != sideswimattacking)
14488 {
14489 23611 dir=left;
14490 23611 }
14491 23611 sideswimdir = left;
14492
14493 23611 holddir=left;
14494
14495
3/4
✓ Branch 0 taken 3323 times.
✓ Branch 1 taken 20288 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3323 times.
23611 if(DrunkUp()&&shiftdir!=down)
14496 {
14497 3323 shiftdir=up;
14498 3323 }
14499
3/4
✓ Branch 0 taken 2542 times.
✓ Branch 1 taken 17746 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2542 times.
20288 else if(DrunkDown()&&shiftdir!=up)
14500 {
14501 2542 shiftdir=down;
14502 2542 }
14503 else
14504 {
14505 17746 shiftdir=-1;
14506 }
14507
14508 23611 do
14509 {
14510 26253 info = walkflag(x-hero_newstep,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep,y+8,1,left);
14511
14512 26253 info = info || walkflag(x-hero_newstep,y+15,1,left);
14513
14514 26253 execute(info);
14515
14516
2/2
✓ Branch 0 taken 5021 times.
✓ Branch 1 taken 21232 times.
26253 if(info.isUnwalkable())
14517 {
14518
2/2
✓ Branch 0 taken 263 times.
✓ Branch 1 taken 4758 times.
5021 if(x != x.getInt())
14519 {
14520 263 x.doRound();
14521 263 }
14522
2/2
✓ Branch 0 taken 2379 times.
✓ Branch 1 taken 2379 times.
4758 else if(hero_newstep > 1)
14523 {
14524
1/2
✓ Branch 0 taken 2379 times.
✗ Branch 1 not taken.
2379 if(hero_newstep != int32_t(hero_newstep)) //floor
14525 2379 hero_newstep = floor((double)hero_newstep);
14526 else --hero_newstep;
14527 2379 }
14528 else
14529 2379 break;
14530 2642 }
14531 21232 else walkable = true;
14532
2/2
✓ Branch 0 taken 2642 times.
✓ Branch 1 taken 21232 times.
23874 }
14533 23874 while(!walkable);
14534
14535 23611 int32_t s=shiftdir;
14536
14537
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 23611 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1405 times.
✓ Branch 7 taken 22206 times.
✓ Branch 8 taken 1382 times.
✓ Branch 9 taken 23 times.
✓ Branch 10 taken 1382 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1382 times.
✗ Branch 13 not taken.
23611 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
14538 {
14539 1382 shiftdir=-1;
14540 1382 }
14541 else
14542 {
14543
2/2
✓ Branch 0 taken 19010 times.
✓ Branch 1 taken 3219 times.
22229 if(s==up)
14544 {
14545 3219 do
14546 {
14547 3740 info = walkflag(x,y+(bigHitbox?0:8)-hero_newstep_diag,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-hero_newstep_diag,1,up);
14548
14549 3740 execute(info);
14550
14551
2/2
✓ Branch 0 taken 999 times.
✓ Branch 1 taken 2741 times.
3740 if(info.isUnwalkable())
14552 {
14553
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 956 times.
999 if(y != y.getInt())
14554 {
14555 43 y.doRound();
14556 43 }
14557
2/2
✓ Branch 0 taken 478 times.
✓ Branch 1 taken 478 times.
956 else if(hero_newstep_diag > 1)
14558 {
14559
1/2
✓ Branch 0 taken 478 times.
✗ Branch 1 not taken.
478 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14560 478 hero_newstep_diag.doFloor();
14561 else --hero_newstep_diag;
14562 478 }
14563 else
14564 478 shiftdir = -1;
14565 999 }
14566
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 542 times.
2741 else if(walkable)
14567 {
14568 2199 do
14569 {
14570 2221 info = walkflag(x-hero_newstep,y+(bigHitbox?0:8)-hero_newstep_diag,1,up);
14571 2221 execute(info);
14572
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 2186 times.
2221 if(info.isUnwalkable())
14573 {
14574
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 26 times.
35 if(y != y.getInt())
14575 {
14576 9 y.doRound();
14577 9 }
14578
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 13 times.
26 else if(hero_newstep_diag > 1)
14579 {
14580
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14581 13 hero_newstep_diag.doFloor();
14582 else --hero_newstep_diag;
14583 13 }
14584 else
14585 13 shiftdir = -1;
14586 35 }
14587 2186 else break;
14588
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 13 times.
35 }
14589 35 while(shiftdir != -1);
14590 2199 break;
14591 }
14592 542 else break;
14593
2/2
✓ Branch 0 taken 521 times.
✓ Branch 1 taken 478 times.
999 }
14594 999 while(shiftdir != -1);
14595 3219 }
14596
2/2
✓ Branch 0 taken 16529 times.
✓ Branch 1 taken 2481 times.
19010 else if(s==down)
14597 {
14598 2481 do
14599 {
14600 2937 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
14601
14602 2937 execute(info);
14603
14604
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 2074 times.
2937 if(info.isUnwalkable())
14605 {
14606
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 814 times.
863 if(y != y.getInt())
14607 {
14608 49 y.doRound();
14609 49 }
14610
2/2
✓ Branch 0 taken 407 times.
✓ Branch 1 taken 407 times.
814 else if(hero_newstep_diag > 1)
14611 {
14612
1/2
✓ Branch 0 taken 407 times.
✗ Branch 1 not taken.
407 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14613 407 hero_newstep_diag.doFloor();
14614 else --hero_newstep_diag;
14615 407 }
14616 else
14617 407 shiftdir = -1;
14618 863 }
14619
2/2
✓ Branch 0 taken 1701 times.
✓ Branch 1 taken 373 times.
2074 else if(walkable)
14620 {
14621 1701 do
14622 {
14623 1704 info = walkflag(x-hero_newstep,y+15+hero_newstep_diag,1,down);
14624 1704 execute(info);
14625
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1699 times.
1704 if(info.isUnwalkable())
14626 {
14627
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
5 if(y != y.getInt())
14628 {
14629 1 y.doRound();
14630 1 }
14631
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if(hero_newstep_diag > 1)
14632 {
14633
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14634 2 hero_newstep_diag.doFloor();
14635 else --hero_newstep_diag;
14636 2 }
14637 else
14638 2 shiftdir = -1;
14639 5 }
14640 1699 else break;
14641
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 }
14642 5 while(shiftdir != -1);
14643 1701 break;
14644 }
14645 373 else break;
14646
2/2
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 407 times.
863 }
14647 863 while(shiftdir != -1);
14648 2481 }
14649 }
14650
14651 23611 move(left);
14652 23611 shiftdir=s;
14653
14654
2/2
✓ Branch 0 taken 21232 times.
✓ Branch 1 taken 2379 times.
23611 if(!walkable)
14655 {
14656
2/2
✓ Branch 0 taken 982 times.
✓ Branch 1 taken 1397 times.
2379 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14657 {
14658 1397 x = x.getInt();
14659 1397 y = y.getInt();
14660 1397 int32_t v1=bigHitbox?0:8;
14661 1397 int32_t v2=bigHitbox?8:12;
14662
14663
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1397 times.
✓ Branch 2 taken 1397 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1221 times.
✓ Branch 5 taken 176 times.
✓ Branch 6 taken 41 times.
✓ Branch 7 taken 1356 times.
1573 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
14664
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 176 times.
✓ Branch 4 taken 135 times.
✓ Branch 5 taken 41 times.
176 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
14665
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
41 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
14666 {
14667
4/8
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 41 times.
41 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
14668 41 sprite::move((zfix)0,(zfix)-1);
14669 41 }
14670
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1356 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1356 times.
✓ Branch 4 taken 135 times.
✓ Branch 5 taken 1221 times.
✓ Branch 6 taken 41 times.
✓ Branch 7 taken 1315 times.
2577 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
14671
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1221 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1221 times.
✓ Branch 4 taken 1180 times.
✓ Branch 5 taken 41 times.
1221 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
14672
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
41 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
14673 {
14674
4/8
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 41 times.
41 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
14675 41 sprite::move((zfix)0,(zfix)1);
14676 41 }
14677 else
14678 {
14679 1315 pushing=push+1;
14680 }
14681 1397 }
14682 else
14683 {
14684 982 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14685
14686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 982 times.
982 if(action!=swimming)
14687 {
14688 982 }
14689 }
14690 2379 }
14691
14692 23611 return;
14693 }
14694 }
14695
14696
5/6
✓ Branch 0 taken 25312 times.
✓ Branch 1 taken 47266 times.
✓ Branch 2 taken 24459 times.
✓ Branch 3 taken 853 times.
✓ Branch 4 taken 24459 times.
✗ Branch 5 not taken.
72578 if(DrunkRight()&&(holddir==-1||holddir==right))
14697 {
14698
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 25312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
25312 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14699 {
14700 }
14701 else
14702 {
14703
3/6
✓ Branch 0 taken 25312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25312 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25312 times.
25312 if(charging==0 && spins==0 && action != sideswimattacking)
14704 {
14705 25312 dir=right;
14706 25312 }
14707 25312 sideswimdir = right;
14708
14709 25312 holddir=right;
14710
14711
3/4
✓ Branch 0 taken 3038 times.
✓ Branch 1 taken 22274 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3038 times.
25312 if(DrunkUp()&&shiftdir!=down)
14712 {
14713 3038 shiftdir=up;
14714 3038 }
14715
4/4
✓ Branch 0 taken 2814 times.
✓ Branch 1 taken 19460 times.
✓ Branch 2 taken 2812 times.
✓ Branch 3 taken 2 times.
22274 else if(DrunkDown()&&shiftdir!=up)
14716 {
14717 2812 shiftdir=down;
14718 2812 }
14719 else
14720 {
14721 19462 shiftdir=-1;
14722 }
14723
14724 25312 do
14725 {
14726 28071 info = walkflag(x+15+hero_newstep,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep,y+8,1,right);;
14727
14728 28071 info = info || walkflag(x+15+hero_newstep,y+15,1,right);
14729
14730 28071 execute(info);
14731
14732
2/2
✓ Branch 0 taken 5229 times.
✓ Branch 1 taken 22842 times.
28071 if(info.isUnwalkable())
14733 {
14734
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 5024 times.
5229 if(x != x.getInt())
14735 {
14736 205 x.doRound();
14737 205 }
14738
2/2
✓ Branch 0 taken 2554 times.
✓ Branch 1 taken 2470 times.
5024 else if(hero_newstep > 1)
14739 {
14740
1/2
✓ Branch 0 taken 2554 times.
✗ Branch 1 not taken.
2554 if(hero_newstep != int32_t(hero_newstep)) //floor
14741 2554 hero_newstep = floor((double)hero_newstep);
14742 else --hero_newstep;
14743 2554 }
14744 else
14745 2470 break;
14746 2759 }
14747 22842 else walkable = true;
14748
2/2
✓ Branch 0 taken 2759 times.
✓ Branch 1 taken 22842 times.
25601 }
14749 25601 while(!walkable);
14750
14751 25312 int32_t s=shiftdir;
14752
14753
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 25312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 2440 times.
✓ Branch 7 taken 22872 times.
✓ Branch 8 taken 2422 times.
✓ Branch 9 taken 18 times.
✓ Branch 10 taken 2422 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2422 times.
✗ Branch 13 not taken.
25312 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
14754 {
14755 2422 shiftdir=-1;
14756 2422 }
14757 else
14758 {
14759
2/2
✓ Branch 0 taken 20115 times.
✓ Branch 1 taken 2775 times.
22890 if(s==up)
14760 {
14761 2775 do
14762 {
14763 3075 info = walkflag(x,y+(bigHitbox?0:8)-hero_newstep_diag,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-hero_newstep_diag,1,up);
14764
14765 3075 execute(info);
14766
14767
2/2
✓ Branch 0 taken 560 times.
✓ Branch 1 taken 2515 times.
3075 if(info.isUnwalkable())
14768 {
14769
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 520 times.
560 if(y != y.getInt())
14770 {
14771 40 y.doRound();
14772 40 }
14773
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 260 times.
520 else if(hero_newstep_diag > 1)
14774 {
14775
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14776 260 hero_newstep_diag.doFloor();
14777 else --hero_newstep_diag;
14778 260 }
14779 else
14780 260 shiftdir = -1;
14781 560 }
14782
2/2
✓ Branch 0 taken 2143 times.
✓ Branch 1 taken 372 times.
2515 else if(walkable)
14783 {
14784 2143 do
14785 {
14786 2163 info = walkflag(x+15+hero_newstep,y+(bigHitbox?0:8)-hero_newstep_diag,1,up);
14787 2163 execute(info);
14788
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 2132 times.
2163 if(info.isUnwalkable())
14789 {
14790
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 22 times.
31 if(y != y.getInt())
14791 {
14792 9 y.doRound();
14793 9 }
14794
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 else if(hero_newstep_diag > 1)
14795 {
14796
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14797 11 hero_newstep_diag.doFloor();
14798 else --hero_newstep_diag;
14799 11 }
14800 else
14801 11 shiftdir = -1;
14802 31 }
14803 2132 else break;
14804
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 11 times.
31 }
14805 31 while(shiftdir != -1);
14806 2143 break;
14807 }
14808 372 else break;
14809
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 260 times.
560 }
14810 560 while(shiftdir != -1);
14811 2775 }
14812
2/2
✓ Branch 0 taken 17450 times.
✓ Branch 1 taken 2665 times.
20115 else if(s==down)
14813 {
14814 2665 do
14815 {
14816 3207 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
14817
14818 3207 execute(info);
14819
14820
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 2187 times.
3207 if(info.isUnwalkable())
14821 {
14822
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 958 times.
1020 if(y != y.getInt())
14823 {
14824 62 y.doRound();
14825 62 }
14826
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 478 times.
958 else if(hero_newstep_diag > 1)
14827 {
14828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14829 480 hero_newstep_diag.doFloor();
14830 else --hero_newstep_diag;
14831 480 }
14832 else
14833 478 shiftdir = -1;
14834 1020 }
14835
2/2
✓ Branch 0 taken 1825 times.
✓ Branch 1 taken 362 times.
2187 else if(walkable)
14836 {
14837 1825 do
14838 {
14839 1836 info = walkflag(x+15+hero_newstep,y+15+hero_newstep_diag,1,down);
14840 1836 execute(info);
14841
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 1818 times.
1836 if(info.isUnwalkable())
14842 {
14843
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 14 times.
18 if(y != y.getInt())
14844 {
14845 4 y.doRound();
14846 4 }
14847
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7 times.
14 else if(hero_newstep_diag > 1)
14848 {
14849
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14850 7 hero_newstep_diag.doFloor();
14851 else --hero_newstep_diag;
14852 7 }
14853 else
14854 7 shiftdir = -1;
14855 18 }
14856 1818 else break;
14857
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 7 times.
18 }
14858 18 while(shiftdir != -1);
14859 1825 break;
14860 }
14861 362 else break;
14862
2/2
✓ Branch 0 taken 542 times.
✓ Branch 1 taken 478 times.
1020 }
14863 1020 while(shiftdir != -1);
14864 2665 }
14865 }
14866
14867 25312 move(right);
14868 25312 shiftdir=s;
14869
14870
2/2
✓ Branch 0 taken 22842 times.
✓ Branch 1 taken 2470 times.
25312 if(!walkable)
14871 {
14872
2/2
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 1684 times.
2470 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14873 {
14874 1684 x = x.getInt();
14875 1684 y = y.getInt();
14876 1684 int32_t v1=bigHitbox?0:8;
14877 1684 int32_t v2=bigHitbox?8:12;
14878
14879
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1684 times.
✓ Branch 2 taken 1684 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1558 times.
✓ Branch 5 taken 126 times.
✓ Branch 6 taken 48 times.
✓ Branch 7 taken 1636 times.
1810 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
14880
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 78 times.
✓ Branch 5 taken 48 times.
126 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
14881
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
48 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
14882 {
14883
4/8
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 48 times.
48 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
14884 48 sprite::move((zfix)0,(zfix)-1);
14885 48 }
14886
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1636 times.
✓ Branch 2 taken 1636 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 78 times.
✓ Branch 5 taken 1558 times.
✓ Branch 6 taken 59 times.
✓ Branch 7 taken 1577 times.
3194 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
14887
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1558 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1558 times.
✓ Branch 4 taken 1499 times.
✓ Branch 5 taken 59 times.
1558 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
14888
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 59 times.
59 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
14889 {
14890
4/8
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 59 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 59 times.
59 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
14891 59 sprite::move((zfix)0,(zfix)1);
14892 59 }
14893 else
14894 {
14895 1577 pushing=push+1;
14896 1577 z3step=2;
14897 }
14898 1684 }
14899 else
14900 {
14901 786 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14902
14903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
786 if(action!=swimming)
14904 {
14905 786 }
14906 }
14907 2470 }
14908
14909 25312 return;
14910 }
14911 }
14912 47266 }
14913 else
14914 {
14915
6/6
✓ Branch 0 taken 22025 times.
✓ Branch 1 taken 87623 times.
✓ Branch 2 taken 21544 times.
✓ Branch 3 taken 481 times.
✓ Branch 4 taken 6529 times.
✓ Branch 5 taken 15015 times.
109648 if(DrunkUp()&&(holddir==-1||holddir==up))
14916 {
14917
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 15496 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
15496 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14918 {
14919 }
14920 else
14921 {
14922
2/4
✓ Branch 0 taken 15496 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15496 times.
15496 if(charging==0 && spins==0)
14923 {
14924 15496 dir=up;
14925 15496 }
14926
14927 15496 holddir=up;
14928
14929
4/4
✓ Branch 0 taken 2451 times.
✓ Branch 1 taken 13045 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 2446 times.
15496 if(DrunkRight()&&shiftdir!=left)
14930 {
14931 2446 shiftdir=right;
14932 2446 }
14933
4/4
✓ Branch 0 taken 2253 times.
✓ Branch 1 taken 10797 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 2249 times.
13050 else if(DrunkLeft()&&shiftdir!=right)
14934 {
14935 2249 shiftdir=left;
14936 2249 }
14937 else
14938 {
14939 10801 shiftdir=-1;
14940 }
14941
14942 //walkable if Ladder can be placed or is already placed vertically
14943
10/18
✓ Branch 0 taken 371 times.
✓ Branch 1 taken 15125 times.
✓ Branch 2 taken 371 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 240 times.
✓ Branch 5 taken 131 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 240 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 240 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 240 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 240 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 240 times.
15496 if(isSideViewHero() && !toogam && !(can_deploy_ladder() || (ladderx && laddery && ladderdir==up)) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14944 {
14945 240 walkable=false;
14946 240 }
14947 else
14948 {
14949 15256 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
14950
14951
2/2
✓ Branch 0 taken 9300 times.
✓ Branch 1 taken 5956 times.
15256 if(x.getInt() & 7)
14952 9300 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
14953 else
14954 5956 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
14955
14956 15256 execute(info);
14957
14958
2/2
✓ Branch 0 taken 981 times.
✓ Branch 1 taken 14275 times.
15256 if(info.isUnwalkable())
14959 {
14960
2/2
✓ Branch 0 taken 930 times.
✓ Branch 1 taken 51 times.
981 if(z3step==2)
14961 {
14962 930 z3step=1;
14963 930 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
14964
14965
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 692 times.
930 if(x.getInt()&7)
14966 692 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
14967 else
14968 238 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
14969
14970 930 execute(info);
14971
14972
2/2
✓ Branch 0 taken 848 times.
✓ Branch 1 taken 82 times.
930 if(info.isUnwalkable())
14973 {
14974 848 walkable = false;
14975 848 }
14976 else
14977 {
14978 82 walkable=true;
14979 }
14980 930 }
14981 else
14982 {
14983 51 walkable=false;
14984 }
14985 981 }
14986 else
14987 {
14988 14275 walkable = true;
14989 }
14990 }
14991
14992 15496 int32_t s=shiftdir;
14993
14994
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 15496 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
15496 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
14995 {
14996 shiftdir=-1;
14997 }
14998 else
14999 {
15000
2/2
✓ Branch 0 taken 2249 times.
✓ Branch 1 taken 13247 times.
15496 if(s==left)
15001 {
15002 2249 info = (walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left));
15003 2249 execute(info);
15004
15005
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 1949 times.
2249 if(info.isUnwalkable())
15006 {
15007 300 shiftdir=-1;
15008 300 }
15009
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 1726 times.
1949 else if(walkable)
15010 {
15011 1726 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,left);
15012 1726 execute(info);
15013
2/2
✓ Branch 0 taken 1723 times.
✓ Branch 1 taken 3 times.
1726 if(info.isUnwalkable())
15014 {
15015 3 shiftdir=-1;
15016 3 }
15017 1726 }
15018 2249 }
15019
2/2
✓ Branch 0 taken 10801 times.
✓ Branch 1 taken 2446 times.
13247 else if(s==right)
15020 {
15021 2446 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
15022 2446 execute(info);
15023
15024
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 2106 times.
2446 if(info.isUnwalkable())
15025 {
15026 340 shiftdir=-1;
15027 340 }
15028
2/2
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 1925 times.
2106 else if(walkable)
15029 {
15030 1925 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,right);
15031 1925 execute(info);
15032
15033
2/2
✓ Branch 0 taken 1923 times.
✓ Branch 1 taken 2 times.
1925 if(info.isUnwalkable())
15034 {
15035 2 shiftdir=-1;
15036 2 }
15037 1925 }
15038 2446 }
15039 }
15040
15041 15496 move(up);
15042 15496 shiftdir=s;
15043
15044
2/2
✓ Branch 0 taken 14357 times.
✓ Branch 1 taken 1139 times.
15496 if(!walkable)
15045 {
15046
2/2
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 669 times.
1139 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15047 {
15048
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 669 times.
✓ Branch 2 taken 669 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 409 times.
✓ Branch 5 taken 260 times.
✓ Branch 6 taken 100 times.
✓ Branch 7 taken 569 times.
929 if(!_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15049
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 260 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 260 times.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 197 times.
260 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15050
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 197 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 197 times.
197 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15051 {
15052
5/8
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 100 times.
100 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
15053 100 sprite::move((zfix)-1,(zfix)0);
15054 100 }
15055 else
15056 {
15057
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 569 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 569 times.
✓ Branch 4 taken 160 times.
✓ Branch 5 taken 409 times.
✓ Branch 6 taken 78 times.
✓ Branch 7 taken 491 times.
978 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15058
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 409 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 409 times.
✓ Branch 4 taken 331 times.
✓ Branch 5 taken 78 times.
409 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15059
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 78 times.
78 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15060 {
15061
4/8
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 78 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 78 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 78 times.
78 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
15062 78 sprite::move((zfix)1,(zfix)0);
15063 78 }
15064 else
15065 {
15066 491 pushing=push+1;
15067 }
15068 }
15069
15070 669 z3step=2;
15071 669 }
15072 else
15073 {
15074 470 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15075 470 z3step=2;
15076 }
15077 1139 }
15078
15079 15496 return;
15080 }
15081 }
15082
15083
6/6
✓ Branch 0 taken 16759 times.
✓ Branch 1 taken 77393 times.
✓ Branch 2 taken 16365 times.
✓ Branch 3 taken 394 times.
✓ Branch 4 taken 11010 times.
✓ Branch 5 taken 5355 times.
94152 if(DrunkDown()&&(holddir==-1||holddir==down))
15084 {
15085
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 11404 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
11404 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15086 {
15087 }
15088 else
15089 {
15090
2/4
✓ Branch 0 taken 11404 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11404 times.
✗ Branch 3 not taken.
11404 if(charging==0 && spins==0)
15091 {
15092 11404 dir=down;
15093 11404 }
15094
15095 11404 holddir=down;
15096
15097
4/4
✓ Branch 0 taken 2159 times.
✓ Branch 1 taken 9245 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2158 times.
11404 if(DrunkRight()&&shiftdir!=left)
15098 {
15099 2158 shiftdir=right;
15100 2158 }
15101
4/4
✓ Branch 0 taken 1697 times.
✓ Branch 1 taken 7549 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1696 times.
9246 else if(DrunkLeft()&&shiftdir!=right)
15102 {
15103 1696 shiftdir=left;
15104 1696 }
15105 else
15106 {
15107 7550 shiftdir=-1;
15108 }
15109
15110 //bool walkable;
15111
7/12
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 11142 times.
✓ Branch 2 taken 262 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 262 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 262 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 262 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 262 times.
11404 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15112 {
15113 262 walkable=false;
15114 262 }
15115 else
15116 {
15117 11142 info = walkflag(x,y+15+z3step,2,down);
15118
15119
2/2
✓ Branch 0 taken 6974 times.
✓ Branch 1 taken 4168 times.
11142 if(x.getInt()&7)
15120 6974 info = info || walkflag(x+16,y+15+z3step,1,down);
15121 else
15122 4168 info = info || walkflagMBlock(x+16, y+15+z3step);
15123
15124 11142 execute(info);
15125
15126
2/2
✓ Branch 0 taken 847 times.
✓ Branch 1 taken 10295 times.
11142 if(info.isUnwalkable())
15127 {
15128
2/2
✓ Branch 0 taken 815 times.
✓ Branch 1 taken 32 times.
847 if(z3step==2)
15129 {
15130 815 z3step=1;
15131 815 info = walkflag(x,y+15+z3step,2,down);
15132
15133
2/2
✓ Branch 0 taken 617 times.
✓ Branch 1 taken 198 times.
815 if(x.getInt()&7)
15134 617 info = info || walkflag(x+16,y+15+z3step,1,down);
15135 else
15136 198 info = info || walkflagMBlock(x+16, y+15+z3step);
15137
15138 815 execute(info);
15139
15140
2/2
✓ Branch 0 taken 769 times.
✓ Branch 1 taken 46 times.
815 if(info.isUnwalkable())
15141 {
15142 769 walkable = false;
15143 769 }
15144 else
15145 {
15146 46 walkable=true;
15147 }
15148 815 }
15149 else
15150 {
15151 32 walkable=false;
15152 }
15153 847 }
15154 else
15155 {
15156 10295 walkable = true;
15157 }
15158 }
15159
15160 11404 int32_t s=shiftdir;
15161
15162
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11404 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11404 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
15163 {
15164 shiftdir=-1;
15165 }
15166 else
15167 {
15168
2/2
✓ Branch 0 taken 1696 times.
✓ Branch 1 taken 9708 times.
11404 if(s==left)
15169 {
15170 1696 info = walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left);
15171 1696 execute(info);
15172
15173
2/2
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 1461 times.
1696 if(info.isUnwalkable())
15174 {
15175 235 shiftdir=-1;
15176 235 }
15177
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 1255 times.
1461 else if(walkable)
15178 {
15179 1255 info = walkflag(x-1,y+16,1,left);
15180 1255 execute(info);
15181
15182
2/2
✓ Branch 0 taken 1251 times.
✓ Branch 1 taken 4 times.
1255 if(info.isUnwalkable())
15183 {
15184 4 shiftdir=-1;
15185 4 }
15186 1255 }
15187 1696 }
15188
2/2
✓ Branch 0 taken 7550 times.
✓ Branch 1 taken 2158 times.
9708 else if(s==right)
15189 {
15190 2158 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
15191 2158 execute(info);
15192
15193
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 1975 times.
2158 if(info.isUnwalkable())
15194 {
15195 183 shiftdir=-1;
15196 183 }
15197
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 1806 times.
1975 else if(walkable)
15198 {
15199 1806 info = walkflag(x+16,y+16,1,right);
15200 1806 execute(info);
15201
15202
2/2
✓ Branch 0 taken 1803 times.
✓ Branch 1 taken 3 times.
1806 if(info.isUnwalkable())
15203 {
15204 3 shiftdir=-1;
15205 3 }
15206 1806 }
15207 2158 }
15208 }
15209
15210 11404 move(down);
15211 11404 shiftdir=s;
15212
15213
2/2
✓ Branch 0 taken 10341 times.
✓ Branch 1 taken 1063 times.
11404 if(!walkable)
15214 {
15215
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 662 times.
1063 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15216 {
15217
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 662 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 662 times.
✓ Branch 4 taken 477 times.
✓ Branch 5 taken 185 times.
✓ Branch 6 taken 44 times.
✓ Branch 7 taken 618 times.
847 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15218
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 185 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 185 times.
✓ Branch 4 taken 86 times.
✓ Branch 5 taken 99 times.
185 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
15219
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15220 {
15221
4/8
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 44 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 44 times.
44 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
15222 44 sprite::move((zfix)-1,(zfix)0);
15223 44 }
15224
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 618 times.
✓ Branch 4 taken 141 times.
✓ Branch 5 taken 477 times.
✓ Branch 6 taken 55 times.
✓ Branch 7 taken 563 times.
1095 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15225
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 477 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 477 times.
✓ Branch 4 taken 422 times.
✓ Branch 5 taken 55 times.
477 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
15226
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 55 times.
55 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15227 {
15228
5/8
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 55 times.
55 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
15229 55 sprite::move((zfix)1,(zfix)0);
15230 55 }
15231 else //if(shiftdir==-1)
15232 {
15233 563 pushing=push+1;
15234
15235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 563 times.
563 if(action!=swimming)
15236 {
15237 563 }
15238 }
15239
15240 662 z3step=2;
15241 662 }
15242 else
15243 {
15244 401 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15245
15246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401 times.
401 if(action!=swimming)
15247 {
15248 401 }
15249
15250 401 z3step=2;
15251 }
15252 1063 }
15253
15254 11404 return;
15255 }
15256 }
15257
15258
6/6
✓ Branch 0 taken 25701 times.
✓ Branch 1 taken 57047 times.
✓ Branch 2 taken 24956 times.
✓ Branch 3 taken 745 times.
✓ Branch 4 taken 24889 times.
✓ Branch 5 taken 67 times.
82748 if(DrunkLeft()&&(holddir==-1||holddir==left))
15259 {
15260
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 25634 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
25634 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15261 {
15262 }
15263 else
15264 {
15265
2/4
✓ Branch 0 taken 25634 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25634 times.
25634 if(charging==0 && spins==0)
15266 {
15267 25634 dir=left;
15268 25634 }
15269
15270 25634 holddir=left;
15271
15272
4/4
✓ Branch 0 taken 2728 times.
✓ Branch 1 taken 22906 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2727 times.
25634 if(DrunkUp()&&shiftdir!=down)
15273 {
15274 2727 shiftdir=up;
15275 2727 }
15276
3/4
✓ Branch 0 taken 2650 times.
✓ Branch 1 taken 20257 times.
✓ Branch 2 taken 2650 times.
✗ Branch 3 not taken.
22907 else if(DrunkDown()&&shiftdir!=up)
15277 {
15278 2650 shiftdir=down;
15279 2650 }
15280 else
15281 {
15282 20257 shiftdir=-1;
15283 }
15284
15285 //bool walkable;
15286 25634 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
15287
15288
2/2
✓ Branch 0 taken 10024 times.
✓ Branch 1 taken 15610 times.
25634 if(y.getInt()&7)
15289 15610 info = info || walkflag(x-z3step,y+16,1,left);
15290
15291 25634 execute(info);
15292
15293
2/2
✓ Branch 0 taken 1794 times.
✓ Branch 1 taken 23840 times.
25634 if(info.isUnwalkable())
15294 {
15295
2/2
✓ Branch 0 taken 1733 times.
✓ Branch 1 taken 61 times.
1794 if(z3step==2)
15296 {
15297 1733 z3step=1;
15298 1733 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
15299
15300
2/2
✓ Branch 0 taken 1308 times.
✓ Branch 1 taken 425 times.
1733 if(y.getInt()&7)
15301 1308 info = info || walkflag(x-z3step,y+16,1,left);
15302
15303 1733 execute(info);
15304
15305
2/2
✓ Branch 0 taken 1671 times.
✓ Branch 1 taken 62 times.
1733 if(info.isUnwalkable())
15306 {
15307 1671 walkable = false;
15308 1671 }
15309 else
15310 {
15311 62 walkable=true;
15312 }
15313 1733 }
15314 else
15315 {
15316 61 walkable=false;
15317 }
15318 1794 }
15319 else
15320 {
15321 23840 walkable = true;
15322 }
15323
15324 25634 int32_t s=shiftdir;
15325
15326
6/14
✗ Branch 0 not taken.
✓ Branch 1 taken 25634 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 6568 times.
✓ Branch 7 taken 19066 times.
✓ Branch 8 taken 6568 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6568 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6568 times.
✗ Branch 13 not taken.
25634 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15327 {
15328 6568 shiftdir=-1;
15329 6568 }
15330 else
15331 {
15332
2/2
✓ Branch 0 taken 16362 times.
✓ Branch 1 taken 2704 times.
19066 if(s==up)
15333 {
15334 2704 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
15335 2704 execute(info);
15336
15337
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 2501 times.
2704 if(info.isUnwalkable())
15338 {
15339 203 shiftdir=-1;
15340 203 }
15341
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 2347 times.
2501 else if(walkable)
15342 {
15343 2347 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,up);
15344 2347 execute(info);
15345
15346
2/2
✓ Branch 0 taken 2343 times.
✓ Branch 1 taken 4 times.
2347 if(info.isUnwalkable())
15347 {
15348 4 shiftdir=-1;
15349 4 }
15350 2347 }
15351 2704 }
15352
2/2
✓ Branch 0 taken 13851 times.
✓ Branch 1 taken 2511 times.
16362 else if(s==down)
15353 {
15354 2511 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
15355 2511 execute(info);
15356
15357
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 2225 times.
2511 if(info.isUnwalkable())
15358 {
15359 286 shiftdir=-1;
15360 286 }
15361
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 2043 times.
2225 else if(walkable)
15362 {
15363 2043 info = walkflag(x-1,y+16,1,down);
15364 2043 execute(info);
15365
15366
2/2
✓ Branch 0 taken 2041 times.
✓ Branch 1 taken 2 times.
2043 if(info.isUnwalkable())
15367 {
15368 2 shiftdir=-1;
15369 2 }
15370 2043 }
15371 2511 }
15372 }
15373
15374 25634 move(left);
15375 25634 shiftdir=s;
15376
15377
2/2
✓ Branch 0 taken 23902 times.
✓ Branch 1 taken 1732 times.
25634 if(!walkable)
15378 {
15379
2/2
✓ Branch 0 taken 356 times.
✓ Branch 1 taken 1376 times.
1732 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15380 {
15381 1376 int32_t v1=bigHitbox?0:8;
15382 1376 int32_t v2=bigHitbox?8:12;
15383
15384
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1376 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1376 times.
✓ Branch 4 taken 1178 times.
✓ Branch 5 taken 198 times.
✓ Branch 6 taken 70 times.
✓ Branch 7 taken 1306 times.
1574 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
15385
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 70 times.
198 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
15386
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
70 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
15387 {
15388
5/8
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 70 times.
70 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
15389 70 sprite::move((zfix)0,(zfix)-1);
15390 70 }
15391
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1306 times.
✓ Branch 2 taken 1306 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 1178 times.
✓ Branch 6 taken 34 times.
✓ Branch 7 taken 1272 times.
2484 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
15392
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1178 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1178 times.
✓ Branch 4 taken 1144 times.
✓ Branch 5 taken 34 times.
1178 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
15393
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
34 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
15394 {
15395
6/8
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 33 times.
34 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
15396 33 sprite::move((zfix)0,(zfix)1);
15397 34 }
15398 else //if(shiftdir==-1)
15399 {
15400 1272 pushing=push+1;
15401
15402
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1263 times.
1272 if(action!=swimming)
15403 {
15404 1263 }
15405 }
15406
15407 1376 z3step=2;
15408 1376 }
15409 else
15410 {
15411 356 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15412
15413
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 350 times.
356 if(action!=swimming)
15414 {
15415 350 }
15416
15417 356 z3step=2;
15418 }
15419 1732 }
15420
15421 25634 return;
15422 }
15423 }
15424
15425
5/6
✓ Branch 0 taken 28503 times.
✓ Branch 1 taken 28611 times.
✓ Branch 2 taken 27739 times.
✓ Branch 3 taken 764 times.
✓ Branch 4 taken 27739 times.
✗ Branch 5 not taken.
57114 if(DrunkRight()&&(holddir==-1||holddir==right))
15426 {
15427
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 28503 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
28503 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15428 {
15429 }
15430 else
15431 {
15432
2/4
✓ Branch 0 taken 28503 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 28503 times.
28503 if(charging==0 && spins==0)
15433 {
15434 28503 dir=right;
15435 28503 }
15436
15437 28503 holddir=right;
15438
15439
4/4
✓ Branch 0 taken 3793 times.
✓ Branch 1 taken 24710 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 3792 times.
28503 if(DrunkUp()&&shiftdir!=down)
15440 {
15441 3792 shiftdir=up;
15442 3792 }
15443
3/4
✓ Branch 0 taken 2705 times.
✓ Branch 1 taken 22006 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2705 times.
24711 else if(DrunkDown()&&shiftdir!=up)
15444 {
15445 2705 shiftdir=down;
15446 2705 }
15447 else
15448 {
15449 22006 shiftdir=-1;
15450 }
15451
15452 //bool walkable;
15453 28503 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
15454
15455
2/2
✓ Branch 0 taken 9911 times.
✓ Branch 1 taken 18592 times.
28503 if(y.getInt()&7)
15456 18592 info = info || walkflag(x+15+z3step,y+16,1,right);
15457
15458 28503 execute(info);
15459
15460
2/2
✓ Branch 0 taken 2335 times.
✓ Branch 1 taken 26168 times.
28503 if(info.isUnwalkable())
15461 {
15462
2/2
✓ Branch 0 taken 2276 times.
✓ Branch 1 taken 59 times.
2335 if(z3step==2)
15463 {
15464 2276 z3step=1;
15465 2276 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
15466
15467
2/2
✓ Branch 0 taken 1577 times.
✓ Branch 1 taken 699 times.
2276 if(y.getInt()&7)
15468 1577 info = info || walkflag(x+15+z3step,y+16,1,right);
15469
15470 2276 execute(info);
15471
15472
2/2
✓ Branch 0 taken 2172 times.
✓ Branch 1 taken 104 times.
2276 if(info.isUnwalkable())
15473 {
15474 2172 walkable = false;
15475 2172 }
15476 else
15477 {
15478 104 walkable=true;
15479 }
15480 2276 }
15481 else
15482 {
15483 59 walkable=false;
15484 }
15485 2335 }
15486 else
15487 {
15488 26168 walkable = true;
15489 }
15490
15491 28503 int32_t s=shiftdir;
15492
15493
6/14
✗ Branch 0 not taken.
✓ Branch 1 taken 28503 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 7520 times.
✓ Branch 7 taken 20983 times.
✓ Branch 8 taken 7520 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7520 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 7520 times.
✗ Branch 13 not taken.
28503 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15494 {
15495 7520 shiftdir=-1;
15496 7520 }
15497 else
15498 {
15499
2/2
✓ Branch 0 taken 17399 times.
✓ Branch 1 taken 3584 times.
20983 if(s==up)
15500 {
15501 3584 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
15502 3584 execute(info);
15503
15504
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 3335 times.
3584 if(info.isUnwalkable())
15505 {
15506 249 shiftdir=-1;
15507 249 }
15508
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 3153 times.
3335 else if(walkable)
15509 {
15510 3153 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,up);
15511 3153 execute(info);
15512
15513
2/2
✓ Branch 0 taken 3149 times.
✓ Branch 1 taken 4 times.
3153 if(info.isUnwalkable())
15514 {
15515 4 shiftdir=-1;
15516 4 }
15517 3153 }
15518 3584 }
15519
2/2
✓ Branch 0 taken 14745 times.
✓ Branch 1 taken 2654 times.
17399 else if(s==down)
15520 {
15521 2654 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
15522 2654 execute(info);
15523
15524
2/2
✓ Branch 0 taken 329 times.
✓ Branch 1 taken 2325 times.
2654 if(info.isUnwalkable())
15525 {
15526 329 shiftdir=-1;
15527 329 }
15528
2/2
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 2167 times.
2325 else if(walkable)
15529 {
15530 2167 info = walkflag(x+16,y+16,1,down);
15531 2167 execute(info);
15532
15533
2/2
✓ Branch 0 taken 2166 times.
✓ Branch 1 taken 1 times.
2167 if(info.isUnwalkable())
15534 {
15535 1 shiftdir=-1;
15536 1 }
15537 2167 }
15538 2654 }
15539 }
15540
15541 28503 move(right);
15542 28503 shiftdir=s;
15543
15544
2/2
✓ Branch 0 taken 26272 times.
✓ Branch 1 taken 2231 times.
28503 if(!walkable)
15545 {
15546
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 1774 times.
2231 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15547 {
15548 1774 int32_t v1=bigHitbox?0:8;
15549 1774 int32_t v2=bigHitbox?8:12;
15550
15551 5322 info = !walkflag(x+16,y+v1,1,right)&&
15552 3548 !walkflag(x+16,y+v2,1,right)&&
15553 1774 walkflag(x+16,y+15,1,right);
15554
15555 //do NOT execute these
15556
2/2
✓ Branch 0 taken 273 times.
✓ Branch 1 taken 1501 times.
1774 if(info.isUnwalkable())
15557 {
15558
5/8
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 272 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 272 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 273 times.
273 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
15559 273 sprite::move((zfix)0,(zfix)-1);
15560 273 }
15561 else
15562 {
15563 4503 info = walkflag(x+16,y+v1, 1,right)&&
15564 3002 !walkflag(x+16,y+v2-1,1,right)&&
15565 1501 !walkflag(x+16,y+15, 1,right);
15566
15567
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 1451 times.
1501 if(info.isUnwalkable())
15568 {
15569
5/8
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 50 times.
50 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
15570 50 sprite::move((zfix)0,(zfix)1);
15571 50 }
15572 else //if(shiftdir==-1)
15573 {
15574 1451 pushing=push+1;
15575 1451 z3step=2;
15576
15577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1451 times.
1451 if(action!=swimming)
15578 {
15579 1451 }
15580 }
15581 }
15582
15583 1774 z3step=2;
15584 1774 }
15585 else
15586 {
15587 457 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15588
15589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(action!=swimming)
15590 {
15591 457 }
15592
15593 457 z3step=2;
15594 }
15595 2231 }
15596
15597 28503 return;
15598 }
15599 }
15600 }
15601
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 75877 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
75877 if(shield_forcedir > -1 && action != rafting)
15602 dir = shield_forcedir;
15603 75877 int32_t wtry = iswaterex(MAPCOMBO(x,y+15), currmap, currscr, -1, x,y+15, true, false);
15604 75877 int32_t wtry8 = iswaterex(MAPCOMBO(x+15,y+15), currmap, currscr, -1, x+15,y+15, true, false);
15605 75877 int32_t wtrx = iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)), currmap, currscr, -1, x,y+(bigHitbox?0:8), true, false);
15606 75877 int32_t wtrx8 = iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)), currmap, currscr, -1, x+15,y+(bigHitbox?0:8), true, false);
15607 75877 int32_t wtrc = iswaterex(MAPCOMBO(x+8,y+(bigHitbox?8:12)), currmap, currscr, -1, x+8,y+(bigHitbox?8:12), true, false);
15608
15609
8/12
✓ Branch 0 taken 20760 times.
✓ Branch 1 taken 55117 times.
✓ Branch 2 taken 20760 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 20760 times.
✓ Branch 6 taken 20760 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 17977 times.
✓ Branch 9 taken 2783 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 17977 times.
75877 if(can_use_item(itype_flippers,i_flippers)&&current_item(itype_flippers) >= combobuf[wtrc].attribytes[0]&&(!(combobuf[wtrc].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))&&!(ladderx+laddery)&&z==0&&fakez==0)
15610 {
15611
7/12
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 17971 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 3 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
17977 if(wtrx&&wtrx8&&wtry&&wtry8 && !DRIEDLAKE)
15612 {
15613 //action=swimming;
15614
2/12
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
3 if(action !=none && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !isSideViewHero())
15615 {
15616 hopclk = 0xFF;
15617 }
15618 3 }
15619 17977 }
15620
15621 75877 return;
15622 } //endif (LTTPWALK)
15623 1151264 temp_step = hero_newstep;
15624 1151264 temp_x = x;
15625 1151264 temp_y = y;
15626
15627
7/8
✓ Branch 0 taken 856026 times.
✓ Branch 1 taken 295238 times.
✓ Branch 2 taken 844014 times.
✓ Branch 3 taken 12012 times.
✓ Branch 4 taken 6490 times.
✓ Branch 5 taken 849536 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 6490 times.
1151264 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15628 {
15629
2/4
✓ Branch 0 taken 6490 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6490 times.
6490 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
15630 goto LEFTRIGHT_NEWMOVE;
15631 6490 else goto LEFTRIGHT_OLDMOVE;
15632 }
15633
15634 // make it easier to get in left & right doors
15635
15636 //ignore ladder for this part. sigh sigh sigh -DD
15637 1144774 oldladderx = ladderx;
15638 1144774 oldladdery = laddery;
15639
2/4
✓ Branch 0 taken 1144774 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1144774 times.
1144774 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
15640 {
15641 if(isdungeon() && DrunkLeft() && (temp_x==32 && temp_y==80))
15642 {
15643 do
15644 {
15645 info = walkflag(temp_x,temp_y+(bigHitbox?0:8),1,left) ||
15646 walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left);
15647
15648 if(info.isUnwalkable())
15649 {
15650 if(temp_x != int32_t(temp_x))
15651 {
15652 temp_x = floor((double)temp_x);
15653 }
15654 else if(temp_step > 1)
15655 {
15656 if(temp_step != int32_t(temp_step)) //floor
15657 temp_step = floor((double)temp_step);
15658 else --temp_step;
15659 }
15660 else
15661 break;
15662 }
15663 }
15664 while(info.isUnwalkable());
15665
15666 if(!info.isUnwalkable())
15667 {
15668 x = temp_x;
15669 y = temp_y;
15670 hero_newstep = temp_step;
15671 //ONLY process the side-effects of the above walkflag if Hero will actually move
15672 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
15673 execute(info);
15674 move(left);
15675 return;
15676 }
15677 temp_x = x;
15678 temp_y = y;
15679 temp_step = hero_newstep;
15680 }
15681
15682 if(isdungeon() && DrunkRight() && temp_x==208 && temp_y==80)
15683 {
15684 do
15685 {
15686 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
15687 walkflag(temp_x+15+temp_step,temp_y+8,1,right);
15688
15689 if(info.isUnwalkable())
15690 {
15691 if(temp_x != int32_t(temp_x))
15692 {
15693 temp_x = floor((double)temp_x);
15694 }
15695 else if(temp_step > 1)
15696 {
15697 if(temp_step != int32_t(temp_step)) //floor
15698 temp_step = floor((double)temp_step);
15699 else --temp_step;
15700 }
15701 else
15702 break;
15703 }
15704 }
15705 while(info.isUnwalkable());
15706
15707 if(!info.isUnwalkable())
15708 {
15709 x = temp_x;
15710 y = temp_y;
15711 hero_newstep = temp_step;
15712 execute(info);
15713 move(right);
15714 return;
15715 }
15716 temp_x = x;
15717 temp_y = y;
15718 temp_step = hero_newstep;
15719 }
15720
15721 ladderx = oldladderx;
15722 laddery = oldladdery;
15723
15724 if(DrunkUp())
15725 {
15726 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
15727 {
15728 if(dir!=up && dir!=down)
15729 {
15730 if(xoff>2&&xoff<6)
15731 {
15732 move(dir);
15733 }
15734 else if(xoff>=6)
15735 {
15736 move(right);
15737 }
15738 else if(xoff>=1)
15739 {
15740 move(left);
15741 }
15742 }
15743 else
15744 {
15745 if(xoff>=4)
15746 {
15747 move(right);
15748 }
15749 else if(xoff<4)
15750 {
15751 move(left);
15752 }
15753 }
15754 }
15755 else
15756 {
15757 do
15758 {
15759 if(action==swimming || IsSideSwim() || action == swimhit)
15760 {
15761 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
15762
15763 if(_walkflag(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, 1,SWITCHBLOCK_STATE) &&
15764 !(iswaterex(MAPCOMBO(temp_x, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x, temp_y+(bigHitbox?0:8)-temp_step, true, false) &&
15765 iswaterex(MAPCOMBO(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, true, false)))
15766 info.setUnwalkable(true);
15767 }
15768 else
15769 {
15770 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
15771 if(x.getInt() & 7)
15772 info = info || walkflag(temp_x+16,temp_y+(bigHitbox?0:8)-temp_step,1,up);
15773 else
15774 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
15775 }
15776
15777 if(info.isUnwalkable())
15778 {
15779 if(temp_y != int32_t(temp_y))
15780 {
15781 temp_y = floor((double)temp_y);
15782 }
15783 else if(temp_step > 1)
15784 {
15785 if(temp_step != int32_t(temp_step)) //floor
15786 temp_step = floor((double)temp_step);
15787 else --temp_step;
15788 }
15789 else
15790 break;
15791 }
15792 }
15793 while(info.isUnwalkable());
15794
15795 execute(info);
15796
15797 if(!info.isUnwalkable())
15798 {
15799 x = temp_x;
15800 y = temp_y;
15801 hero_newstep = temp_step;
15802 move(up);
15803 return;
15804 }
15805
15806 if(!DrunkLeft() && !DrunkRight())
15807 {
15808 if(NO_GRIDLOCK)
15809 {
15810 x = x.getInt();
15811 y = y.getInt();
15812 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15813 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15814 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15815 {
15816 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
15817 sprite::move((zfix)-1,(zfix)0);
15818 }
15819 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15820 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15821 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15822 {
15823 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
15824 sprite::move((zfix)1,(zfix)0);
15825 }
15826 else
15827 {
15828 pushing=push+1;
15829 }
15830 }
15831 else pushing=push+1;
15832
15833 if(charging==0 && spins==0)
15834 {
15835 dir=up;
15836 }
15837
15838 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15839 {
15840 herostep();
15841 }
15842
15843 return;
15844 }
15845 else
15846 {
15847 goto LEFTRIGHT_NEWMOVE;
15848 }
15849 }
15850
15851 return;
15852 }
15853
15854 if(DrunkDown())
15855 {
15856 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
15857 {
15858 if(dir!=up && dir!=down)
15859 {
15860 if(xoff>2&&xoff<6)
15861 {
15862 move(dir);
15863 }
15864 else if(xoff>=6)
15865 {
15866 move(right);
15867 }
15868 else if(xoff>=1)
15869 {
15870 move(left);
15871 }
15872 }
15873 else
15874 {
15875 if(xoff>=4)
15876 {
15877 move(right);
15878 }
15879 else if(xoff<4)
15880 {
15881 move(left);
15882 }
15883 }
15884 }
15885 else
15886 {
15887 do
15888 {
15889 if(action==swimming || IsSideSwim() || action == swimhit)
15890 {
15891 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
15892
15893 if(_walkflag(temp_x+15, temp_y+15+temp_step, 1,SWITCHBLOCK_STATE) &&
15894 !(iswaterex(MAPCOMBO(temp_x, temp_y+15+temp_step), currmap, currscr, -1, temp_x, temp_y+15+temp_step, true, false) &&
15895 iswaterex(MAPCOMBO(temp_x+15, temp_y+15+temp_step), currmap, currscr, -1, temp_x+15, temp_y+15+temp_step, true, false)))
15896 info.setUnwalkable(true);
15897 }
15898 else
15899 {
15900 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
15901 if(x.getInt() & 7)
15902 info = info || walkflag(temp_x+16,temp_y+15+temp_step,1,down);
15903 else
15904 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
15905 }
15906
15907 if(info.isUnwalkable())
15908 {
15909 if(temp_y != int32_t(temp_y))
15910 {
15911 temp_y = floor((double)temp_y);
15912 }
15913 else if(temp_step > 1)
15914 {
15915 if(temp_step != int32_t(temp_step)) //floor
15916 temp_step = floor((double)temp_step);
15917 else --temp_step;
15918 }
15919 else
15920 break;
15921 }
15922 }
15923 while(info.isUnwalkable());
15924
15925 execute(info);
15926
15927 if(!info.isUnwalkable())
15928 {
15929 x = temp_x;
15930 y = temp_y;
15931 hero_newstep = temp_step;
15932 move(down);
15933 return;
15934 }
15935
15936 if(!DrunkLeft() && !DrunkRight())
15937 {
15938 if(NO_GRIDLOCK)
15939 {
15940 x = x.getInt();
15941 y = y.getInt();
15942 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15943 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
15944 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15945 {
15946 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
15947 sprite::move((zfix)-1,(zfix)0);
15948 }
15949 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15950 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
15951 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15952 {
15953 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
15954 sprite::move((zfix)1,(zfix)0);
15955 }
15956 else
15957 {
15958 pushing=push+1;
15959 }
15960 }
15961 else pushing=push+1;
15962
15963 if(charging==0 && spins==0)
15964 {
15965 dir=down;
15966 }
15967
15968 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15969 {
15970 herostep();
15971 }
15972
15973 return;
15974 }
15975 else goto LEFTRIGHT_NEWMOVE;
15976 }
15977
15978 return;
15979 }
15980
15981 LEFTRIGHT_NEWMOVE:
15982 temp_x = x;
15983 temp_y = y;
15984 temp_step = hero_newstep;
15985 if(isdungeon() && (temp_y<=26 || temp_y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15986 {
15987 return;
15988 }
15989
15990 if(DrunkLeft())
15991 {
15992 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
15993 {
15994 if(dir!=left && dir!=right)
15995 {
15996 if(yoff>2&&yoff<6)
15997 {
15998 move(dir);
15999 }
16000 else if(yoff>=6)
16001 {
16002 move(down);
16003 }
16004 else if(yoff>=1)
16005 {
16006 move(up);
16007 }
16008 }
16009 else
16010 {
16011 if(yoff>=4)
16012 {
16013 move(down);
16014 }
16015 else if(yoff<4)
16016 {
16017 move(up);
16018 }
16019 }
16020 }
16021 else
16022 {
16023 do
16024 {
16025 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) ||
16026 walkflag(temp_x-temp_step,temp_y+(isSideViewHero() ?0:8), 1,left);
16027
16028 if(y.getInt() & 7)
16029 info = info || walkflag(temp_x-temp_step,temp_y+16,1,left);
16030
16031 if(info.isUnwalkable())
16032 {
16033 if(temp_x != int32_t(temp_x))
16034 {
16035 temp_x = floor((double)temp_x);
16036 }
16037 else if(temp_step > 1)
16038 {
16039 if(temp_step != int32_t(temp_step)) //floor
16040 temp_step = floor((double)temp_step);
16041 else --temp_step;
16042 }
16043 else
16044 break;
16045 }
16046 }
16047 while(info.isUnwalkable());
16048
16049 execute(info);
16050
16051 if(!info.isUnwalkable())
16052 {
16053 x = temp_x;
16054 y = temp_y;
16055 hero_newstep = temp_step;
16056 move(left);
16057 return;
16058 }
16059
16060 if(!DrunkUp() && !DrunkDown())
16061 {
16062 if(NO_GRIDLOCK)
16063 {
16064 x = x.getInt();
16065 y = y.getInt();
16066 int32_t v1=bigHitbox?0:8;
16067 int32_t v2=bigHitbox?8:12;
16068
16069 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16070 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
16071 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
16072 {
16073 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
16074 sprite::move((zfix)0,(zfix)-1);
16075 }
16076 else if(_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16077 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
16078 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
16079 {
16080 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
16081 sprite::move((zfix)0,(zfix)1);
16082 }
16083 else
16084 {
16085 pushing=push+1;
16086 }
16087 }
16088 else pushing=push+1;
16089
16090 if(charging==0 && spins==0)
16091 {
16092 dir=left;
16093 }
16094
16095 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16096 {
16097 herostep();
16098 }
16099
16100 return;
16101 }
16102 }
16103
16104 return;
16105 }
16106
16107 if(DrunkRight())
16108 {
16109 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16110 {
16111 if(dir!=left && dir!=right)
16112 {
16113 if(yoff>2&&yoff<6)
16114 {
16115 move(dir);
16116 }
16117 else if(yoff>=6)
16118 {
16119 move(down);
16120 }
16121 else if(yoff>=1)
16122 {
16123 move(up);
16124 }
16125 }
16126 else
16127 {
16128 if(yoff>=4)
16129 {
16130 move(down);
16131 }
16132 else if(yoff<4)
16133 {
16134 move(up);
16135 }
16136 }
16137 }
16138 else
16139 {
16140 do
16141 {
16142 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
16143 walkflag(temp_x+15+temp_step,temp_y+(isSideViewHero() ?0:8),1,right);
16144
16145 if(y.getInt() & 7)
16146 info = info || walkflag(temp_x+15+temp_step,y+16,1,right);
16147
16148 if(info.isUnwalkable())
16149 {
16150 if(temp_x != int32_t(temp_x))
16151 {
16152 temp_x = floor((double)temp_x);
16153 }
16154 else if(temp_step > 1)
16155 {
16156 if(temp_step != int32_t(temp_step)) //floor
16157 temp_step = floor((double)temp_step);
16158 else --temp_step;
16159 }
16160 else
16161 break;
16162 }
16163 }
16164 while(info.isUnwalkable());
16165
16166 execute(info);
16167
16168 if(!info.isUnwalkable())
16169 {
16170 x = temp_x;
16171 y = temp_y;
16172 hero_newstep = temp_step;
16173 move(right);
16174 return;
16175 }
16176
16177 if(!DrunkUp() && !DrunkDown())
16178 {
16179 if(NO_GRIDLOCK)
16180 {
16181 x = x.getInt();
16182 y = y.getInt();
16183 int32_t v1=bigHitbox?0:8;
16184 int32_t v2=bigHitbox?8:12;
16185
16186 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16187 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
16188 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16189 {
16190 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
16191 sprite::move((zfix)0,(zfix)-1);
16192 }
16193 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16194 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
16195 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16196 {
16197 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
16198 sprite::move((zfix)0,(zfix)1);
16199 }
16200 else
16201 {
16202 pushing=push+1;
16203 }
16204 }
16205 else pushing=push+1;
16206
16207 if(charging==0 && spins==0)
16208 {
16209 dir=right;
16210 }
16211
16212 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16213 {
16214 herostep();
16215 }
16216
16217 return;
16218 }
16219 }
16220 }
16221 }
16222 else
16223 {
16224 2289548 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
16225 1144774 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
16226
16227
10/10
✓ Branch 0 taken 849536 times.
✓ Branch 1 taken 295238 times.
✓ Branch 2 taken 96608 times.
✓ Branch 3 taken 752928 times.
✓ Branch 4 taken 67203 times.
✓ Branch 5 taken 29405 times.
✓ Branch 6 taken 518 times.
✓ Branch 7 taken 66685 times.
✓ Branch 8 taken 438 times.
✓ Branch 9 taken 80 times.
1144774 if(isdungeon() && DrunkLeft() && !info.isUnwalkable() && (x==32 && y==80))
16228 {
16229 //ONLY process the side-effects of the above walkflag if Hero will actually move
16230 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
16231 438 execute(info);
16232 438 move(left);
16233 438 return;
16234 }
16235
16236 2288672 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) ||
16237 1144336 walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
16238
16239
10/10
✓ Branch 0 taken 849098 times.
✓ Branch 1 taken 295238 times.
✓ Branch 2 taken 105604 times.
✓ Branch 3 taken 743494 times.
✓ Branch 4 taken 71357 times.
✓ Branch 5 taken 34247 times.
✓ Branch 6 taken 619 times.
✓ Branch 7 taken 70738 times.
✓ Branch 8 taken 83 times.
✓ Branch 9 taken 536 times.
1144336 if(isdungeon() && DrunkRight() && !info.isUnwalkable() && x==208 && y==80)
16240 {
16241 536 execute(info);
16242 536 move(right);
16243 536 return;
16244 }
16245
16246 1143800 ladderx = oldladderx;
16247 1143800 laddery = oldladdery;
16248
16249
2/2
✓ Branch 0 taken 121241 times.
✓ Branch 1 taken 1022559 times.
1143800 if(DrunkUp())
16250 {
16251
11/14
✓ Branch 0 taken 3351 times.
✓ Branch 1 taken 117890 times.
✓ Branch 2 taken 3299 times.
✓ Branch 3 taken 52 times.
✓ Branch 4 taken 3155 times.
✓ Branch 5 taken 144 times.
✓ Branch 6 taken 3155 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3155 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3155 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 3152 times.
121241 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16252 {
16253
3/4
✓ Branch 0 taken 3119 times.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3119 times.
3152 if(dir!=up && dir!=down)
16254 {
16255
4/4
✓ Branch 0 taken 2141 times.
✓ Branch 1 taken 978 times.
✓ Branch 2 taken 929 times.
✓ Branch 3 taken 1212 times.
3119 if(xoff>2&&xoff<6)
16256 {
16257 1212 move(dir);
16258 1212 }
16259
2/2
✓ Branch 0 taken 929 times.
✓ Branch 1 taken 978 times.
1907 else if(xoff>=6)
16260 {
16261 929 move(right);
16262 929 }
16263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 978 times.
978 else if(xoff>=1)
16264 {
16265 978 move(left);
16266 978 }
16267 3119 }
16268 else
16269 {
16270
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 23 times.
33 if(xoff>=4)
16271 {
16272 10 move(right);
16273 10 }
16274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 else if(xoff<4)
16275 {
16276 23 move(left);
16277 23 }
16278 }
16279 3152 }
16280 else
16281 {
16282
4/6
✓ Branch 0 taken 115728 times.
✓ Branch 1 taken 2361 times.
✓ Branch 2 taken 115728 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 115728 times.
118089 if(action==swimming || IsSideSwim() || action == swimhit)
16283 {
16284 2361 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
16285
16286
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2361 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2361 times.
✓ Branch 4 taken 57 times.
✓ Branch 5 taken 2304 times.
✓ Branch 6 taken 2162 times.
✓ Branch 7 taken 199 times.
4665 if(_walkflag(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
16287
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 2108 times.
4412 !(iswaterex(MAPCOMBO(x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])) &&
16288 2108 iswaterex(MAPCOMBO(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]))))
16289 199 info.setUnwalkable(true);
16290 2361 }
16291 else
16292 {
16293 115728 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
16294
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 115673 times.
115728 if(x.getInt() & 7)
16295 55 info = info || walkflag(x+16,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),1,up);
16296 else
16297 115673 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
16298 }
16299
16300 118089 execute(info);
16301
16302
2/2
✓ Branch 0 taken 44171 times.
✓ Branch 1 taken 73918 times.
118089 if(!info.isUnwalkable())
16303 {
16304 73918 move(up);
16305 73918 return;
16306 }
16307
16308
4/4
✓ Branch 0 taken 40909 times.
✓ Branch 1 taken 3262 times.
✓ Branch 2 taken 3878 times.
✓ Branch 3 taken 37031 times.
44171 if(!DrunkLeft() && !DrunkRight())
16309 {
16310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37031 times.
37031 if(NO_GRIDLOCK)
16311 {
16312 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16313 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16314 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16315 {
16316 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
16317 sprite::move((zfix)-1,(zfix)0);
16318 }
16319 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16320 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16321 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16322 {
16323 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
16324 sprite::move((zfix)1,(zfix)0);
16325 }
16326 else
16327 {
16328 pushing=push+1;
16329 }
16330 }
16331 37031 else pushing=push+1;
16332
16333
4/4
✓ Branch 0 taken 36848 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 36752 times.
✓ Branch 3 taken 96 times.
37031 if(charging==0 && spins==0)
16334 {
16335 36752 dir=up;
16336 36752 }
16337
16338
5/8
✓ Branch 0 taken 36949 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 36949 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36949 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 36949 times.
37031 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16339 {
16340 36949 herostep();
16341 36949 }
16342
16343 37031 return;
16344 }
16345 else
16346 {
16347 7140 goto LEFTRIGHT_OLDMOVE;
16348 }
16349 }
16350
16351 3152 return;
16352 }
16353
16354
2/2
✓ Branch 0 taken 102879 times.
✓ Branch 1 taken 919680 times.
1022559 if(DrunkDown())
16355 {
16356
11/14
✓ Branch 0 taken 2800 times.
✓ Branch 1 taken 100079 times.
✓ Branch 2 taken 2579 times.
✓ Branch 3 taken 221 times.
✓ Branch 4 taken 2384 times.
✓ Branch 5 taken 195 times.
✓ Branch 6 taken 2384 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2384 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2384 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 2383 times.
102879 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16357 {
16358
3/4
✓ Branch 0 taken 2383 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2382 times.
2383 if(dir!=up && dir!=down)
16359 {
16360
4/4
✓ Branch 0 taken 1715 times.
✓ Branch 1 taken 667 times.
✓ Branch 2 taken 733 times.
✓ Branch 3 taken 982 times.
2382 if(xoff>2&&xoff<6)
16361 {
16362 982 move(dir);
16363 982 }
16364
2/2
✓ Branch 0 taken 733 times.
✓ Branch 1 taken 667 times.
1400 else if(xoff>=6)
16365 {
16366 733 move(right);
16367 733 }
16368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 667 times.
667 else if(xoff>=1)
16369 {
16370 667 move(left);
16371 667 }
16372 2382 }
16373 else
16374 {
16375
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(xoff>=4)
16376 {
16377 1 move(right);
16378 1 }
16379 else if(xoff<4)
16380 {
16381 move(left);
16382 }
16383 }
16384 2383 }
16385 else
16386 {
16387
4/6
✓ Branch 0 taken 97525 times.
✓ Branch 1 taken 2971 times.
✓ Branch 2 taken 97525 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 97525 times.
100496 if(action==swimming || IsSideSwim() || action == swimhit)
16388 {
16389 2971 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
16390
16391
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2971 times.
✓ Branch 2 taken 2971 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 187 times.
✓ Branch 5 taken 2784 times.
✓ Branch 6 taken 2586 times.
✓ Branch 7 taken 385 times.
5755 if(_walkflag(x+15, y+15+int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
16392
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 2399 times.
5183 !(iswaterex(MAPCOMBO(x, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+15+int32_t(lsteps[y.getInt()&7])) &&
16393 2399 iswaterex(MAPCOMBO(x+15, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+15+int32_t(lsteps[y.getInt()&7]))))
16394 385 info.setUnwalkable(true);
16395 2971 }
16396 else
16397 {
16398 97525 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
16399
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 97302 times.
97525 if(x.getInt() & 7)
16400 223 info = (info || walkflag(x+16,y+15+int32_t(lsteps[y.getInt()&7]),1,down));
16401 else
16402 97302 info = (info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7])));
16403 }
16404
16405 100496 execute(info);
16406
16407
2/2
✓ Branch 0 taken 40775 times.
✓ Branch 1 taken 59721 times.
100496 if(!info.isUnwalkable())
16408 {
16409 59721 move(down);
16410 59721 return;
16411 }
16412
16413
4/4
✓ Branch 0 taken 37929 times.
✓ Branch 1 taken 2846 times.
✓ Branch 2 taken 3122 times.
✓ Branch 3 taken 34807 times.
40775 if(!DrunkLeft() && !DrunkRight())
16414 {
16415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34807 times.
34807 if(NO_GRIDLOCK)
16416 {
16417 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16418 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
16419 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16420 {
16421 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
16422 sprite::move((zfix)-1,(zfix)0);
16423 }
16424 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16425 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
16426 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16427 {
16428 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
16429 sprite::move((zfix)1,(zfix)0);
16430 }
16431 else
16432 {
16433 pushing=push+1;
16434 }
16435 }
16436 34807 else pushing=push+1;
16437
16438
2/4
✓ Branch 0 taken 34807 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34807 times.
✗ Branch 3 not taken.
34807 if(charging==0 && spins==0)
16439 {
16440 34807 dir=down;
16441 34807 }
16442
16443
5/8
✓ Branch 0 taken 34581 times.
✓ Branch 1 taken 226 times.
✓ Branch 2 taken 34581 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34581 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 34581 times.
34807 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16444 {
16445 34581 herostep();
16446 34581 }
16447
16448 34807 return;
16449 }
16450 5968 else goto LEFTRIGHT_OLDMOVE;
16451 }
16452
16453 2383 return;
16454 }
16455
16456 LEFTRIGHT_OLDMOVE:
16457
16458
7/8
✓ Branch 0 taken 698437 times.
✓ Branch 1 taken 240841 times.
✓ Branch 2 taken 675719 times.
✓ Branch 3 taken 22718 times.
✓ Branch 4 taken 6868 times.
✓ Branch 5 taken 691569 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 6868 times.
939278 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
16459 {
16460 6868 return;
16461 }
16462
16463
2/2
✓ Branch 0 taken 128198 times.
✓ Branch 1 taken 804212 times.
932410 if(DrunkLeft())
16464 {
16465
11/14
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 125760 times.
✓ Branch 2 taken 2415 times.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 2385 times.
✓ Branch 5 taken 30 times.
✓ Branch 6 taken 2385 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2385 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2385 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✓ Branch 13 taken 2383 times.
128198 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16466 {
16467
3/4
✓ Branch 0 taken 2378 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2378 times.
2383 if(dir!=left && dir!=right)
16468 {
16469
4/4
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 686 times.
✓ Branch 2 taken 733 times.
✓ Branch 3 taken 959 times.
2378 if(yoff>2&&yoff<6)
16470 {
16471 959 move(dir);
16472 959 }
16473
2/2
✓ Branch 0 taken 733 times.
✓ Branch 1 taken 686 times.
1419 else if(yoff>=6)
16474 {
16475 733 move(down);
16476 733 }
16477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 686 times.
686 else if(yoff>=1)
16478 {
16479 686 move(up);
16480 686 }
16481 2378 }
16482 else
16483 {
16484
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(yoff>=4)
16485 {
16486 5 move(down);
16487 5 }
16488 else if(yoff<4)
16489 {
16490 move(up);
16491 }
16492 }
16493 2383 }
16494 else
16495 {
16496 251630 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
16497 125815 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero() ?0:8), 1,left);
16498
16499 125815 execute(info);
16500
16501
2/2
✓ Branch 0 taken 33798 times.
✓ Branch 1 taken 92017 times.
125815 if(!info.isUnwalkable())
16502 {
16503 92017 move(left);
16504 92017 return;
16505 }
16506
16507
4/4
✓ Branch 0 taken 32541 times.
✓ Branch 1 taken 1257 times.
✓ Branch 2 taken 1302 times.
✓ Branch 3 taken 31239 times.
33798 if(!DrunkUp() && !DrunkDown())
16508 {
16509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31239 times.
31239 if(NO_GRIDLOCK)
16510 {
16511 int32_t v1=bigHitbox?0:8;
16512 int32_t v2=bigHitbox?8:12;
16513
16514 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16515 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
16516 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
16517 {
16518 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
16519 sprite::move((zfix)0,(zfix)-1);
16520 }
16521 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
16522 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
16523 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
16524 {
16525 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
16526 sprite::move((zfix)0,(zfix)1);
16527 }
16528 else
16529 {
16530 pushing=push+1;
16531 }
16532 }
16533 31239 else pushing=push+1;
16534
16535
3/4
✓ Branch 0 taken 31233 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31233 times.
31239 if(charging==0 && spins==0)
16536 {
16537 31233 dir=left;
16538 31233 }
16539
16540
5/8
✓ Branch 0 taken 30955 times.
✓ Branch 1 taken 284 times.
✓ Branch 2 taken 30955 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30955 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 30955 times.
31239 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16541 {
16542 30955 herostep();
16543 30955 }
16544
16545 31239 return;
16546 }
16547 }
16548
16549 4942 return;
16550 }
16551
16552
2/2
✓ Branch 0 taken 664980 times.
✓ Branch 1 taken 139232 times.
804212 if(DrunkRight())
16553 {
16554
10/14
✓ Branch 0 taken 2483 times.
✓ Branch 1 taken 136749 times.
✓ Branch 2 taken 2459 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 2420 times.
✓ Branch 5 taken 39 times.
✓ Branch 6 taken 2420 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2420 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2420 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 2420 times.
139232 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16555 {
16556
4/4
✓ Branch 0 taken 2417 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 2414 times.
2420 if(dir!=left && dir!=right)
16557 {
16558
4/4
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 694 times.
✓ Branch 2 taken 700 times.
✓ Branch 3 taken 1020 times.
2414 if(yoff>2&&yoff<6)
16559 {
16560 1020 move(dir);
16561 1020 }
16562
2/2
✓ Branch 0 taken 700 times.
✓ Branch 1 taken 694 times.
1394 else if(yoff>=6)
16563 {
16564 700 move(down);
16565 700 }
16566
1/2
✓ Branch 0 taken 694 times.
✗ Branch 1 not taken.
694 else if(yoff>=1)
16567 {
16568 694 move(up);
16569 694 }
16570 2414 }
16571 else
16572 {
16573
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5 times.
6 if(yoff>=4)
16574 {
16575 1 move(down);
16576 1 }
16577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 else if(yoff<4)
16578 {
16579 5 move(up);
16580 5 }
16581 }
16582 2420 }
16583 else
16584 {
16585 273624 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right)
16586 136812 || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero()?0:8),1,right);
16587
16588 136812 execute(info);
16589
16590
2/2
✓ Branch 0 taken 39022 times.
✓ Branch 1 taken 97790 times.
136812 if(!info.isUnwalkable())
16591 {
16592 97790 move(right);
16593 97790 return;
16594 }
16595
16596
4/4
✓ Branch 0 taken 37362 times.
✓ Branch 1 taken 1660 times.
✓ Branch 2 taken 1095 times.
✓ Branch 3 taken 36267 times.
39022 if(!DrunkUp() && !DrunkDown())
16597 {
16598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36267 times.
36267 if(NO_GRIDLOCK)
16599 {
16600 int32_t v1=bigHitbox?0:8;
16601 int32_t v2=bigHitbox?8:12;
16602
16603 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16604 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
16605 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16606 {
16607 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
16608 sprite::move((zfix)0,(zfix)-1);
16609 }
16610 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16611 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
16612 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16613 {
16614 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
16615 sprite::move((zfix)0,(zfix)1);
16616 }
16617 else
16618 {
16619 pushing=push+1;
16620 }
16621 }
16622 36267 else pushing=push+1;
16623
16624
2/4
✓ Branch 0 taken 36267 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 36267 times.
36267 if(charging==0 && spins==0)
16625 {
16626 36267 dir=right;
16627 36267 }
16628
16629
5/8
✓ Branch 0 taken 36216 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 36216 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36216 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 36216 times.
36267 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16630 {
16631 36216 herostep();
16632 36216 }
16633
16634 36267 return;
16635 }
16636 }
16637 5175 }
16638 }
16639 3275113 }
16640
16641 //solid ffc checking should probably be moved to here.
16642 1894094 void HeroClass::move(int32_t d2, int32_t forceRate)
16643 {
16644
4/6
✓ Branch 0 taken 1893857 times.
✓ Branch 1 taken 237 times.
✓ Branch 2 taken 1893857 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1893857 times.
1894094 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
16645 237 return;
16646
16647
3/4
✓ Branch 0 taken 1811952 times.
✓ Branch 1 taken 81905 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1811952 times.
1893857 if(!get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) && !IsSideSwim())
16648 {
16649 1811952 moveOld(d2);
16650 1811952 return;
16651 }
16652
16653
4/8
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 78929 times.
✓ Branch 2 taken 2976 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2976 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
160834 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1) && ((z==0 && fakez==0) || tmpscr->flags2&fAIRCOMBOS)) ||
16654
5/6
✓ Branch 0 taken 4699 times.
✓ Branch 1 taken 74230 times.
✓ Branch 2 taken 1836 times.
✓ Branch 3 taken 2863 times.
✓ Branch 4 taken 4699 times.
✗ Branch 5 not taken.
78929 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1));
16655 //!DIMITODO: add QR for slow combos under hero
16656
2/2
✓ Branch 0 taken 163810 times.
✓ Branch 1 taken 81905 times.
245715 for (int32_t i = 0; i <= 1; ++i)
16657 {
16658
2/2
✓ Branch 0 taken 50357 times.
✓ Branch 1 taken 113453 times.
163810 if(tmpscr2[i].valid!=0)
16659 {
16660
2/2
✓ Branch 0 taken 2442 times.
✓ Branch 1 taken 111011 times.
113453 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
16661 {
16662
2/4
✓ Branch 0 taken 111011 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111011 times.
✗ Branch 3 not taken.
111011 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && !_walkflag_layer(x+7,y+8,1, &(tmpscr2[i]))) slowcombo = false;
16663 111011 }
16664 else
16665 {
16666
2/4
✓ Branch 0 taken 2442 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2442 times.
✗ Branch 3 not taken.
2442 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && _effectflag_layer(x+7,y+8,1, &(tmpscr2[i]))) slowcombo = false;
16667 }
16668 113453 }
16669 163810 }
16670
1/2
✓ Branch 0 taken 81905 times.
✗ Branch 1 not taken.
81905 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
16671 81905 bool is_swimming = (action == swimming);
16672 81905 bool fastSwim = (zinit.hero_swim_speed>60);
16673 81905 zfix rate(steprate);
16674 81905 int32_t shieldid = getCurrentActiveShield();
16675
1/2
✓ Branch 0 taken 81905 times.
✗ Branch 1 not taken.
81905 if(shieldid > -1)
16676 {
16677 itemdata const& shield = itemsbuf[shieldid];
16678 if(shield.flags & ITEM_FLAG10) //Change Speed flag
16679 {
16680 zfix perc = shield.misc7;
16681 perc /= 100;
16682 if(perc < 0)
16683 perc = (perc*-1)+1;
16684 rate = (rate * perc) + shield.misc8;
16685 }
16686 }
16687
16688 81905 zfix dx, dy;
16689 81905 zfix movepix(rate / 100);
16690 81905 zfix step(movepix);
16691 81905 zfix step_diag(movepix);
16692 81905 zfix up_step(game->get_sideswim_up() / -100.0);
16693 81905 zfix left_step(game->get_sideswim_side() / -100.0);
16694 81905 zfix right_step(game->get_sideswim_side() / 100.0);
16695 81905 zfix down_step(game->get_sideswim_down() / 100.0);
16696 81905 bool checkladder = false;
16697
16698
2/2
✓ Branch 0 taken 81904 times.
✓ Branch 1 taken 1 times.
81905 if(hero_newstep > movepix) hero_newstep = movepix;
16699
2/2
✓ Branch 0 taken 81904 times.
✓ Branch 1 taken 1 times.
81905 if(hero_newstep_diag > movepix) hero_newstep_diag = movepix;
16700 //2/3 speed
16701
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 81905 times.
✓ Branch 2 taken 78929 times.
✓ Branch 3 taken 78929 times.
✓ Branch 4 taken 81905 times.
✓ Branch 5 taken 78929 times.
81905 if((is_swimming && fastSwim) || (!is_swimming && (slowcharging ^ slowcombo)))
16702 {
16703 160834 step = ((step / 3.0) * 2);
16704 160834 step_diag = ((step_diag / 3.0) * 2);
16705 160834 up_step = ((up_step / 3.0) * 2);
16706 160834 left_step = ((left_step / 3.0) * 2);
16707 160834 right_step = ((right_step / 3.0) * 2);
16708 160834 down_step = ((down_step / 3.0) * 2);
16709 160834 }
16710 //1/2 speed
16711
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 78929 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 78929 times.
78929 else if((is_swimming && !fastSwim) || (slowcharging && slowcombo))
16712 {
16713 step /= 2;
16714 step_diag /= 2;
16715 up_step /= 2;
16716 left_step /= 2;
16717 right_step /= 2;
16718 down_step /= 2;
16719 }
16720 //normal speed
16721 else
16722 {
16723 //no modification
16724 }
16725
16726
1/2
✓ Branch 0 taken 81905 times.
✗ Branch 1 not taken.
81905 if(diagonalMovement)
16727 {
16728 //zprint2("Player's X is %d, Y is %d\n", x, y);
16729
6/6
✓ Branch 0 taken 65508 times.
✓ Branch 1 taken 16397 times.
✓ Branch 2 taken 67710 times.
✓ Branch 3 taken 2202 times.
✓ Branch 4 taken 29056 times.
✓ Branch 5 taken 55051 times.
125596 if(((d2 == up || d2 == down) && (shiftdir == left || shiftdir == right)) ||
16730
4/4
✓ Branch 0 taken 50082 times.
✓ Branch 1 taken 47880 times.
✓ Branch 2 taken 4189 times.
✓ Branch 3 taken 45893 times.
2202 (d2 == left || d2 == right) && (shiftdir == up || shiftdir == down))
16731 {
16732
2/4
✓ Branch 0 taken 17696 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17696 times.
127798 if(hero_newstep > 0 && hero_newstep_diag > 0)
16733 {
16734 17696 step = STEP_DIAGONAL(step);
16735 17696 step_diag = STEP_DIAGONAL(step_diag);
16736 17696 up_step = STEP_DIAGONAL(up_step);
16737 17696 left_step = STEP_DIAGONAL(left_step);
16738 17696 right_step = STEP_DIAGONAL(right_step);
16739 17696 down_step = STEP_DIAGONAL(down_step);
16740 17696 }
16741 17696 }
16742
2/2
✓ Branch 0 taken 56961 times.
✓ Branch 1 taken 6628 times.
63589 if(hero_newstep < step) step = hero_newstep; //handle collision
16743
2/2
✓ Branch 0 taken 60811 times.
✓ Branch 1 taken 2778 times.
63589 if(hero_newstep_diag < step_diag) step_diag = hero_newstep_diag; //handle collision
16744
5/5
✓ Branch 0 taken 18316 times.
✓ Branch 1 taken 16397 times.
✓ Branch 2 taken 16585 times.
✓ Branch 3 taken 23611 times.
✓ Branch 4 taken 25312 times.
63589 switch(d2)
16745 {
16746 case up:
16747
3/3
✓ Branch 0 taken 12956 times.
✓ Branch 1 taken 1674 times.
✓ Branch 2 taken 1767 times.
16397 switch(shiftdir)
16748 {
16749 case left:
16750 1674 dx = -step_diag;
16751
1/2
✓ Branch 0 taken 1674 times.
✗ Branch 1 not taken.
1674 if (IsSideSwim()) dx = left_step;
16752 1674 break;
16753 case right:
16754 1767 dx = step_diag;
16755
1/2
✓ Branch 0 taken 1767 times.
✗ Branch 1 not taken.
1767 if (IsSideSwim()) dx = right_step;
16756 1767 break;
16757 }
16758
2/2
✓ Branch 0 taken 2514 times.
✓ Branch 1 taken 13883 times.
16397 if(walkable)
16759 {
16760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13883 times.
13883 if (!IsSideSwim()) dy = -step;
16761
1/2
✓ Branch 0 taken 13883 times.
✗ Branch 1 not taken.
13883 if (IsSideSwim())
16762 {
16763 dy = up_step;
16764 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
16765 }
16766 13883 }
16767 16397 break;
16768 case down:
16769
3/3
✓ Branch 0 taken 11814 times.
✓ Branch 1 taken 2252 times.
✓ Branch 2 taken 2519 times.
16585 switch(shiftdir)
16770 {
16771 case left:
16772 2252 dx = -step_diag;
16773
1/2
✓ Branch 0 taken 2252 times.
✗ Branch 1 not taken.
2252 if (IsSideSwim()) dx = left_step;
16774 2252 break;
16775 case right:
16776 2519 dx = step_diag;
16777
1/2
✓ Branch 0 taken 2519 times.
✗ Branch 1 not taken.
2519 if (IsSideSwim()) dx = right_step;
16778 2519 break;
16779 }
16780
2/2
✓ Branch 0 taken 2469 times.
✓ Branch 1 taken 14116 times.
16585 if(walkable)
16781 {
16782 14116 dy = step;
16783
1/2
✓ Branch 0 taken 14116 times.
✗ Branch 1 not taken.
14116 if (IsSideSwim()) dy = down_step;
16784 14116 }
16785 16585 break;
16786 case left:
16787
3/3
✓ Branch 0 taken 18811 times.
✓ Branch 1 taken 2728 times.
✓ Branch 2 taken 2072 times.
23611 switch(shiftdir)
16788 {
16789 case up:
16790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2728 times.
2728 if (!IsSideSwim()) dy = -step_diag;
16791
1/2
✓ Branch 0 taken 2728 times.
✗ Branch 1 not taken.
2728 if (IsSideSwim())
16792 {
16793 dy = up_step;
16794 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
16795 }
16796 2728 break;
16797 case down:
16798 2072 dy = step_diag;
16799
1/2
✓ Branch 0 taken 2072 times.
✗ Branch 1 not taken.
2072 if (IsSideSwim()) dy = down_step;
16800 2072 break;
16801 }
16802
2/2
✓ Branch 0 taken 2379 times.
✓ Branch 1 taken 21232 times.
23611 if(walkable)
16803 {
16804 21232 dx = -step;
16805
1/2
✓ Branch 0 taken 21232 times.
✗ Branch 1 not taken.
21232 if (IsSideSwim()) dx = left_step;
16806 21232 }
16807 23611 break;
16808 case right:
16809
3/3
✓ Branch 0 taken 20628 times.
✓ Branch 1 taken 2504 times.
✓ Branch 2 taken 2180 times.
25312 switch(shiftdir)
16810 {
16811 case up:
16812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2504 times.
2504 if (!IsSideSwim()) dy = -step_diag;
16813
1/2
✓ Branch 0 taken 2504 times.
✗ Branch 1 not taken.
2504 if (IsSideSwim())
16814 {
16815 dy = up_step;
16816 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
16817 }
16818 2504 break;
16819 case down:
16820 2180 dy = step_diag;
16821
1/2
✓ Branch 0 taken 2180 times.
✗ Branch 1 not taken.
2180 if (IsSideSwim()) dy = down_step;
16822 2180 break;
16823 }
16824
2/2
✓ Branch 0 taken 2470 times.
✓ Branch 1 taken 22842 times.
25312 if(walkable)
16825 {
16826 22842 dx = step;
16827
1/2
✓ Branch 0 taken 22842 times.
✗ Branch 1 not taken.
22842 if (IsSideSwim()) dx = right_step;
16828 22842 }
16829 25312 break;
16830 };
16831 100221 }
16832 else
16833 {
16834 if(hero_newstep < step) step = hero_newstep; //handle collision
16835 switch(d2)
16836 {
16837 case up:
16838 dy -= step;
16839 if (IsSideSwim()) dy = up_step;
16840 break;
16841 case down:
16842 dy += step;
16843 if (IsSideSwim()) dy = down_step;
16844 break;
16845 case left:
16846 dx -= step;
16847 if (IsSideSwim()) dx = left_step;
16848 break;
16849 case right:
16850 dx += step;
16851 if (IsSideSwim()) dx = right_step;
16852 break;
16853 };
16854 }
16855 100221 hero_newstep = movepix;
16856 100221 hero_newstep_diag = movepix;
16857
16858
6/16
✗ Branch 0 not taken.
✓ Branch 1 taken 100221 times.
✓ Branch 2 taken 81905 times.
✓ Branch 3 taken 18316 times.
✓ Branch 4 taken 81905 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 81905 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 81905 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
100221 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
16859 {
16860 81905 dir=d2;
16861 81905 }
16862
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 18316 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
18316 else if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
16863 {
16864 dir = shiftdir;
16865 }
16866
1/2
✓ Branch 0 taken 100221 times.
✗ Branch 1 not taken.
100221 if(forceRate > -1)
16867 {
16868 checkladder = false;
16869 switch(dir)
16870 {
16871 case right:
16872 case r_up:
16873 case r_down:
16874 dx = zfix(forceRate) / 100;
16875 break;
16876 case left:
16877 case l_up:
16878 case l_down:
16879 dx = zfix(-forceRate) / 100;
16880 break;
16881 default:
16882 dx = 0;
16883 }
16884 switch(dir)
16885 {
16886 case down:
16887 case r_down:
16888 case l_down:
16889 dy = zfix(forceRate) / 100;
16890 break;
16891 case up:
16892 case r_up:
16893 case l_up:
16894 dy = zfix(-forceRate) / 100;
16895 break;
16896 default:
16897 dy = 0;
16898 }
16899 }
16900
4/4
✓ Branch 0 taken 29619 times.
✓ Branch 1 taken 70602 times.
✓ Branch 2 taken 23113 times.
✓ Branch 3 taken 6506 times.
100221 if(dx == 0 && dy == 0) return;
16901
5/8
✓ Branch 0 taken 75399 times.
✓ Branch 1 taken 18316 times.
✓ Branch 2 taken 75399 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 75399 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 75399 times.
93715 if(action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16902 {
16903 75399 herostep();
16904
16905 //ack... don't walk if in midair! -DD
16906
10/14
✓ Branch 0 taken 75399 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75399 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 75399 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 75399 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4274 times.
✓ Branch 9 taken 71125 times.
✓ Branch 10 taken 1621 times.
✓ Branch 11 taken 2653 times.
✓ Branch 12 taken 179 times.
✓ Branch 13 taken 1442 times.
75399 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
16907 {
16908 73957 action=walking; FFCore.setHeroAction(walking);
16909 73957 }
16910
16911
2/2
✓ Branch 0 taken 71541 times.
✓ Branch 1 taken 3858 times.
75399 if(++hero_count > (16*hero_animation_speed))
16912 3858 hero_count=0;
16913 75399 }
16914
1/2
✓ Branch 0 taken 18316 times.
✗ Branch 1 not taken.
18316 else if(!(frame & 1))
16915 {
16916 herostep();
16917 }
16918
16919
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93715 times.
✓ Branch 2 taken 18316 times.
✓ Branch 3 taken 18316 times.
93715 if(charging==0 || attack!=wHammer)
16920 {
16921 112031 sprite::move(dx, dy);
16922 112031 WalkflagInfo info;
16923 112031 info = walkflag(x,y+8-(bigHitbox*8)-4,2,up);
16924 112031 execute(info);
16925
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 75399 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 75399 times.
✗ Branch 7 not taken.
112031 if (checkladder && !canSideviewLadderRemote(x, y-4) && !info.isUnwalkable() && (y + 8 - (bigHitbox * 8) - 4) > 0)
16926 {
16927 if (game->get_sideswim_jump() != 0)
16928 {
16929 setFall(zfix(0-(FEATHERJUMP*(game->get_sideswim_jump()/10000.0))));
16930 sfx(WAV_ZN1SPLASH,(int32_t)x);
16931 hopclk = 0;
16932 if (charging || spins) action = attacking;
16933 else action = none;
16934 }
16935 else
16936 {
16937 sprite::move(zfix(0), zfix(-1*dy));
16938 }
16939 }
16940 75399 }
16941 1912410 }
16942
16943 1811952 void HeroClass::moveOld(int32_t d2)
16944 {
16945 //al_trace("%s\n",d2==up?"up":d2==down?"down":d2==left?"left":d2==right?"right":"?");
16946 static bool totalskip = false;
16947
16948
3/6
✓ Branch 0 taken 1811952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1811952 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1811952 times.
1811952 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
16949 return;
16950
16951 1811952 int32_t dx=0,dy=0;
16952 1811952 int32_t xstep=lsteps[x.getInt()&7];
16953 1811952 int32_t ystep=lsteps[y.getInt()&7];
16954 1811952 int32_t z3skip=0;
16955 1811952 int32_t z3diagskip=0;
16956
3/6
✓ Branch 0 taken 54733 times.
✓ Branch 1 taken 1757219 times.
✓ Branch 2 taken 54733 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3569171 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && ((z==0 && fakez == 0) || tmpscr->flags2&fAIRCOMBOS)) ||
16957
5/6
✓ Branch 0 taken 16184 times.
✓ Branch 1 taken 1741035 times.
✓ Branch 2 taken 8953 times.
✓ Branch 3 taken 7231 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8953 times.
1757219 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement);
16958
2/2
✓ Branch 0 taken 1811366 times.
✓ Branch 1 taken 586 times.
1811952 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
16959 1811952 bool is_swimming = (action == swimming);
16960
16961 //slow walk combo, or charging, moves at 2/3 speed
16962 if(
16963
4/4
✓ Branch 0 taken 1793680 times.
✓ Branch 1 taken 18272 times.
✓ Branch 2 taken 55096 times.
✓ Branch 3 taken 1738584 times.
1830224 (!is_swimming && (slowcharging ^ slowcombo))||
16964
2/2
✓ Branch 0 taken 18272 times.
✓ Branch 1 taken 1738584 times.
1756856 (is_swimming && (zinit.hero_swim_speed>60))
16965 )
16966 {
16967 73368 totalskip = false;
16968
16969
2/2
✓ Branch 0 taken 4647 times.
✓ Branch 1 taken 68721 times.
73368 if(diagonalMovement)
16970 {
16971 4647 skipstep=(skipstep+1)%6;
16972
16973
2/2
✓ Branch 0 taken 2359 times.
✓ Branch 1 taken 2288 times.
4647 if(skipstep%2==0) z3skip=1;
16974 2359 else z3skip=0;
16975
16976
2/2
✓ Branch 0 taken 3136 times.
✓ Branch 1 taken 1511 times.
4647 if(skipstep%3==0) z3diagskip=1;
16977 3136 else z3diagskip=0;
16978 4647 }
16979 else
16980 {
16981
2/2
✓ Branch 0 taken 47092 times.
✓ Branch 1 taken 21629 times.
68721 if(d2<left)
16982 {
16983
2/2
✓ Branch 0 taken 28378 times.
✓ Branch 1 taken 18714 times.
47092 if(ystep>1)
16984 {
16985 18714 skipstep^=1;
16986 18714 ystep=skipstep;
16987 18714 }
16988 47092 }
16989 else
16990 {
16991
2/2
✓ Branch 0 taken 13135 times.
✓ Branch 1 taken 8494 times.
21629 if(xstep>1)
16992 {
16993 8494 skipstep^=1;
16994 8494 xstep=skipstep;
16995 8494 }
16996 }
16997 }
16998 73368 }
16999 // else if(is_swimming || (slowcharging && slowcombo))
17000 else if(
17001
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1738584 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1738695 (is_swimming && (zinit.hero_swim_speed<60))||
17002
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 1738473 times.
1738584 (slowcharging && slowcombo)
17003 )
17004 {
17005 //swimming, or charging on a slow combo, moves at 1/2 speed
17006 111 totalskip = !totalskip;
17007
17008
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(diagonalMovement)
17009 {
17010 skipstep=0;
17011 }
17012 111 }
17013 else
17014 {
17015 1738473 totalskip = false;
17016
17017
2/2
✓ Branch 0 taken 1662083 times.
✓ Branch 1 taken 76390 times.
1738473 if(diagonalMovement)
17018 {
17019 76390 skipstep=0;
17020 76390 }
17021 }
17022
17023
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 1811896 times.
1811952 if(!totalskip)
17024 {
17025
2/2
✓ Branch 0 taken 81037 times.
✓ Branch 1 taken 1730859 times.
1811896 if(diagonalMovement)
17026 {
17027
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 15496 times.
✓ Branch 2 taken 11404 times.
✓ Branch 3 taken 28503 times.
✓ Branch 4 taken 25634 times.
81037 switch(d2)
17028 {
17029 case up:
17030
2/2
✓ Branch 0 taken 1946 times.
✓ Branch 1 taken 13550 times.
15496 if(shiftdir==left)
17031 {
17032
2/2
✓ Branch 0 taken 1723 times.
✓ Branch 1 taken 223 times.
1946 if(walkable)
17033 {
17034 1723 dy-=1-z3diagskip;
17035 1723 dx-=1-z3diagskip;
17036 1723 z3step=2;
17037 1723 }
17038 else
17039 {
17040 223 dx-=1-z3diagskip;
17041 223 z3step=2;
17042 }
17043 1946 }
17044
2/2
✓ Branch 0 taken 2104 times.
✓ Branch 1 taken 11446 times.
13550 else if(shiftdir==right)
17045 {
17046
2/2
✓ Branch 0 taken 1923 times.
✓ Branch 1 taken 181 times.
2104 if(walkable)
17047 {
17048 1923 dy-=1-z3diagskip;
17049 1923 dx+=1-z3diagskip;
17050 1923 z3step=2;
17051 1923 }
17052 else
17053 {
17054 181 dx+=1-z3diagskip;
17055 181 z3step=2;
17056 }
17057 2104 }
17058 else
17059 {
17060
2/2
✓ Branch 0 taken 735 times.
✓ Branch 1 taken 10711 times.
11446 if(walkable)
17061 {
17062 10711 dy-=z3step-z3skip;
17063 10711 z3step=(z3step%2)+1;
17064 10711 }
17065 }
17066
17067 15496 break;
17068
17069 case down:
17070
2/2
✓ Branch 0 taken 1457 times.
✓ Branch 1 taken 9947 times.
11404 if(shiftdir==left)
17071 {
17072
2/2
✓ Branch 0 taken 1251 times.
✓ Branch 1 taken 206 times.
1457 if(walkable)
17073 {
17074 1251 dy+=1-z3diagskip;
17075 1251 dx-=1-z3diagskip;
17076 1251 z3step=2;
17077 1251 }
17078 else
17079 {
17080 206 dx-=1-z3diagskip;
17081 206 z3step=2;
17082 }
17083 1457 }
17084
2/2
✓ Branch 0 taken 1972 times.
✓ Branch 1 taken 7975 times.
9947 else if(shiftdir==right)
17085 {
17086
2/2
✓ Branch 0 taken 1803 times.
✓ Branch 1 taken 169 times.
1972 if(walkable)
17087 {
17088 1803 dy+=1-z3diagskip;
17089 1803 dx+=1-z3diagskip;
17090 1803 z3step=2;
17091 1803 }
17092 else
17093 {
17094 169 dx+=1-z3diagskip;
17095 169 z3step=2;
17096 }
17097 1972 }
17098 else
17099 {
17100
2/2
✓ Branch 0 taken 688 times.
✓ Branch 1 taken 7287 times.
7975 if(walkable)
17101 {
17102 7287 dy+=z3step-z3skip;
17103 7287 z3step=(z3step%2)+1;
17104 7287 }
17105 }
17106
17107 11404 break;
17108
17109 case right:
17110
2/2
✓ Branch 0 taken 25172 times.
✓ Branch 1 taken 3331 times.
28503 if(shiftdir==up)
17111 {
17112
2/2
✓ Branch 0 taken 3149 times.
✓ Branch 1 taken 182 times.
3331 if(walkable)
17113 {
17114 3149 dy-=1-z3diagskip;
17115 3149 dx+=1-z3diagskip;
17116 3149 z3step=2;
17117 3149 }
17118 else
17119 {
17120 182 dy-=1-z3diagskip;
17121 182 z3step=2;
17122 }
17123 3331 }
17124
2/2
✓ Branch 0 taken 2324 times.
✓ Branch 1 taken 22848 times.
25172 else if(shiftdir==down)
17125 {
17126
2/2
✓ Branch 0 taken 2166 times.
✓ Branch 1 taken 158 times.
2324 if(walkable)
17127 {
17128 2166 dy+=1-z3diagskip;
17129 2166 dx+=1-z3diagskip;
17130 2166 z3step=2;
17131 2166 }
17132 else
17133 {
17134 158 dy+=1-z3diagskip;
17135 158 z3step=2;
17136 }
17137 2324 }
17138 else
17139 {
17140
2/2
✓ Branch 0 taken 1891 times.
✓ Branch 1 taken 20957 times.
22848 if(walkable)
17141 {
17142 20957 dx+=z3step-z3skip;
17143 20957 z3step=(z3step%2)+1;
17144 20957 }
17145 }
17146
17147 28503 break;
17148
17149 case left:
17150
2/2
✓ Branch 0 taken 23137 times.
✓ Branch 1 taken 2497 times.
25634 if(shiftdir==up)
17151 {
17152
2/2
✓ Branch 0 taken 2343 times.
✓ Branch 1 taken 154 times.
2497 if(walkable)
17153 {
17154 2343 dy-=1-z3diagskip;
17155 2343 dx-=1-z3diagskip;
17156 2343 z3step=2;
17157 2343 }
17158 else
17159 {
17160 154 dy-=1-z3diagskip;
17161 154 z3step=2;
17162 }
17163 2497 }
17164
2/2
✓ Branch 0 taken 2223 times.
✓ Branch 1 taken 20914 times.
23137 else if(shiftdir==down)
17165 {
17166
2/2
✓ Branch 0 taken 2041 times.
✓ Branch 1 taken 182 times.
2223 if(walkable)
17167 {
17168 2041 dy+=1-z3diagskip;
17169 2041 dx-=1-z3diagskip;
17170 2041 z3step=2;
17171 2041 }
17172 else
17173 {
17174 182 dy+=1-z3diagskip;
17175 182 z3step=2;
17176 }
17177 2223 }
17178 else
17179 {
17180
2/2
✓ Branch 0 taken 1396 times.
✓ Branch 1 taken 19518 times.
20914 if(walkable)
17181 {
17182 19518 dx-=z3step-z3skip;
17183 19518 z3step=(z3step%2)+1;
17184 19518 }
17185 }
17186
17187 25634 break;
17188 }
17189 81037 }
17190 else
17191 {
17192
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 414454 times.
✓ Branch 2 taken 327386 times.
✓ Branch 3 taken 477112 times.
✓ Branch 4 taken 511907 times.
1730859 switch(d2)
17193 {
17194 case up:
17195
7/14
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 414146 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 308 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 308 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 308 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 308 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 308 times.
414454 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy-=ystep;
17196
17197 414454 break;
17198
17199 case down:
17200
7/14
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 327332 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 54 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 54 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 54 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 54 times.
327386 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy+=ystep;
17201
17202 327386 break;
17203
17204 case left:
17205 477112 dx-=xstep;
17206 477112 break;
17207
17208 case right:
17209 511907 dx+=xstep;
17210 511907 break;
17211 }
17212 }
17213 1811896 }
17214
17215
8/16
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 1811366 times.
✓ Branch 2 taken 1811087 times.
✓ Branch 3 taken 865 times.
✓ Branch 4 taken 1811082 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 1811082 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1811082 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
1811952 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
17216 {
17217 1811082 dir=d2;
17218 1811082 }
17219
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 870 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
870 else if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
17220 {
17221 dir = shiftdir;
17222 }
17223
17224
3/4
✓ Branch 0 taken 1793680 times.
✓ Branch 1 taken 18272 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1793680 times.
1811952 if(action != swimming && !IsSideSwim())
17225 {
17226 1793680 herostep();
17227
17228 //ack... don't walk if in midair! -DD
17229
12/14
✓ Branch 0 taken 1793094 times.
✓ Branch 1 taken 586 times.
✓ Branch 2 taken 1792815 times.
✓ Branch 3 taken 279 times.
✓ Branch 4 taken 1792655 times.
✓ Branch 5 taken 160 times.
✓ Branch 6 taken 1792655 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 16184 times.
✓ Branch 9 taken 1776471 times.
✓ Branch 10 taken 8953 times.
✓ Branch 11 taken 7231 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 8953 times.
1793680 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
17230 {
17231 1783702 action=walking; FFCore.setHeroAction(walking);
17232 1783702 }
17233
17234
2/2
✓ Branch 0 taken 1698722 times.
✓ Branch 1 taken 94958 times.
1793680 if(++hero_count > (16*hero_animation_speed))
17235 94958 hero_count=0;
17236 1793680 }
17237
2/2
✓ Branch 0 taken 9128 times.
✓ Branch 1 taken 9144 times.
18272 else if(!(frame & 1))
17238 {
17239 9144 herostep();
17240 9144 }
17241
17242
3/4
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 1811366 times.
✓ Branch 2 taken 586 times.
✗ Branch 3 not taken.
1811952 if(charging==0 || attack!=wHammer)
17243 {
17244 1811952 sprite::move((zfix)dx,(zfix)dy);
17245 1811952 }
17246 1811952 }
17247
17248 8066995 HeroClass::WalkflagInfo HeroClass::walkflag(zfix fx,zfix fy,int32_t cnt,byte d2)
17249 {
17250 8066995 return walkflag(fx.getInt(), fy.getInt(), cnt, d2);
17251 }
17252 8066995 HeroClass::WalkflagInfo HeroClass::walkflag(int32_t wx,int32_t wy,int32_t cnt,byte d2)
17253 {
17254 8066995 WalkflagInfo ret;
17255
17256 8066995 wx = vbound(wx, -1, 256);
17257 8066995 wy = vbound(wy, -1, 176);
17258
17259
7/8
✓ Branch 0 taken 8039058 times.
✓ Branch 1 taken 27937 times.
✓ Branch 2 taken 8017954 times.
✓ Branch 3 taken 21104 times.
✓ Branch 4 taken 8017954 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1061 times.
✓ Branch 7 taken 8016893 times.
8066995 if (wx < 0 || wx > 255 || wy < 0 || wy > 175)
17260 {
17261 50102 ret.setUnwalkable(false);
17262 50102 return ret;
17263 }
17264
17265
2/2
✓ Branch 0 taken 41482 times.
✓ Branch 1 taken 7975411 times.
8016893 if(toogam)
17266 {
17267 41482 ret.setUnwalkable(false);
17268 41482 return ret;
17269 }
17270
17271
4/4
✓ Branch 0 taken 144389 times.
✓ Branch 1 taken 7831022 times.
✓ Branch 2 taken 144102 times.
✓ Branch 3 taken 287 times.
7975411 if(blockpath && wy<(bigHitbox?80:88))
17272 {
17273 287 ret.setUnwalkable(true);
17274 287 return ret;
17275 }
17276
17277
4/4
✓ Branch 0 taken 55906 times.
✓ Branch 1 taken 7919218 times.
✓ Branch 2 taken 42519 times.
✓ Branch 3 taken 13387 times.
7975124 if(blockmoving && mblock2.hit(wx,wy,0,1,1,1))
17278 {
17279 13387 ret.setUnwalkable(true);
17280 13387 return ret;
17281 }
17282
17283
2/2
✓ Branch 0 taken 6265 times.
✓ Branch 1 taken 7955472 times.
7961737 if (collide_object(wx, wy,1, 1))
17284 {
17285 6265 ret.setUnwalkable(true);
17286 6265 return ret;
17287 }
17288
17289
14/20
✓ Branch 0 taken 5409267 times.
✓ Branch 1 taken 2546205 times.
✓ Branch 2 taken 5182934 times.
✓ Branch 3 taken 226333 times.
✓ Branch 4 taken 4983269 times.
✓ Branch 5 taken 199665 times.
✓ Branch 6 taken 199665 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 199665 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 129143 times.
✓ Branch 13 taken 70522 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 70522 times.
✓ Branch 16 taken 70522 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 6250 times.
✓ Branch 19 taken 7949222 times.
8099789 if(isdungeon() && currscr<128 && wy<(bigHitbox?32:40) && (((diagonalMovement||NO_GRIDLOCK)?(x<=112||x>=128):x!=120) || _walkflag(120,24,2,SWITCHBLOCK_STATE))
17290
2/2
✓ Branch 0 taken 15174 times.
✓ Branch 1 taken 55348 times.
199665 && !get_bit(quest_rules,qr_FREEFORM))
17291 {
17292 6250 ret.setUnwalkable(true);
17293 6250 return ret;
17294 }
17295
17296
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7949222 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7949222 times.
7949222 bool wf = _walkflag(wx,wy,cnt,SWITCHBLOCK_STATE);
17297
17298
6/6
✓ Branch 0 taken 5403017 times.
✓ Branch 1 taken 2546205 times.
✓ Branch 2 taken 5176684 times.
✓ Branch 3 taken 226333 times.
✓ Branch 4 taken 2438471 times.
✓ Branch 5 taken 2738213 times.
7949222 if(isdungeon() && currscr<128 && !get_bit(quest_rules,qr_FREEFORM))
17299 {
17300
2/4
✓ Branch 0 taken 2738213 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2738213 times.
2738213 if((diagonalMovement||NO_GRIDLOCK))
17301 {
17302 if(wx>=112&&wx<120&&wy<40&&wy>=32) wf=true;
17303
17304 if(wx>=136&&wx<144&&wy<40&&wy>=32) wf=true;
17305 }
17306 2738213 }
17307 //All problems related to exiting water are probably here. -Z
17308
3/4
✓ Branch 0 taken 7836928 times.
✓ Branch 1 taken 112294 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7836928 times.
7949222 if(action==swimming || IsSideSwim())
17309 {
17310
2/2
✓ Branch 0 taken 104294 times.
✓ Branch 1 taken 8000 times.
112294 if(!wf)
17311 {
17312 8000 bool isthissolid = false;
17313
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8000 times.
✓ Branch 4 taken 4204 times.
✓ Branch 5 taken 3796 times.
12204 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
17314
4/6
✓ Branch 0 taken 3796 times.
✓ Branch 1 taken 4204 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4204 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4204 times.
8000 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
17315
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4204 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4204 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4204 times.
4204 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
17316
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4204 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4204 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4204 times.
8000 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
17317 //This checks if Hero is currently swimming in solid water (cause even if the QR "No Hopping" is enabled, he should still hop out of solid water) - Dimi
17318
17319
17320
5/6
✓ Branch 0 taken 6945 times.
✓ Branch 1 taken 1055 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6945 times.
✓ Branch 4 taken 1747 times.
✓ Branch 5 taken 9747 times.
9055 if(landswim>= (get_bit(quest_rules,qr_DROWN) && isSwimming() ? 1
17321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1055 times.
1055 : (!diagonalMovement) ? 1 : (get_bit(quest_rules,qr_NO_HOPPING)?1:22)))
17322 {
17323 //Check for out of bounds for swimming
17324 1747 bool changehop = true;
17325
17326
4/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 1328 times.
✓ Branch 2 taken 1328 times.
✓ Branch 3 taken 909 times.
1747 if((diagonalMovement||NO_GRIDLOCK))
17327 {
17328
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2656 if(wx<0||wy<0)
17329 changehop = false;
17330 else if(wx>248)
17331 changehop = false;
17332 else if(wx>240&&cnt==2)
17333 changehop = false;
17334 else if(wy>168)
17335 changehop = false;
17336 }
17337
3/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 490 times.
✓ Branch 2 taken 909 times.
✗ Branch 3 not taken.
909 if ((get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) changehop = false;
17338 //This may be where the hang-up for exiting water exists. -Z
17339 // hop out of the water
17340
2/2
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 419 times.
909 if(changehop)
17341 419 ret.setHopClk(1);
17342 909 }
17343 else
17344 {
17345
6/6
✓ Branch 0 taken 3441 times.
✓ Branch 1 taken 6306 times.
✓ Branch 2 taken 3345 times.
✓ Branch 3 taken 6402 times.
✓ Branch 4 taken 2262 times.
✓ Branch 5 taken 1083 times.
9747 if((!(get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) || isthissolid) && (dir==d2 || shiftdir==d2))
17346 {
17347 //int32_t vx=((int32_t)x+4)&0xFFF8;
17348 //int32_t vy=((int32_t)y+4)&0xFFF8;
17349
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 1059 times.
3345 if(d2==left)
17350 {
17351
2/4
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
240 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?6:11)), currmap, currscr, -1, x-1,y+(bigHitbox?6:11)) &&
17352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?9:12)), currmap, currscr, -1, x-1,y+(bigHitbox?9:12)) &&
17353
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 120 times.
120 !_walkflag(x-1,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
17354
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
120 !_walkflag(x-1,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
17355 {
17356 120 ret.setHopDir(d2);
17357 120 ret.setIlswim(true);
17358 120 }
17359 else ret.setIlswim(false);
17360 120 }
17361
2/2
✓ Branch 0 taken 916 times.
✓ Branch 1 taken 143 times.
1059 else if(d2==right)
17362 {
17363
4/4
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 696 times.
✓ Branch 2 taken 220 times.
✓ Branch 3 taken 696 times.
1136 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?6:11)), currmap, currscr, -1, x+16,y+(bigHitbox?6:11)) &&
17364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 220 times.
220 !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?9:12)), currmap, currscr, -1, x+16,y+(bigHitbox?9:12)) &&
17365
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 220 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 220 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 220 times.
220 !_walkflag(x+16,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
17366
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 220 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 220 times.
220 !_walkflag(x+16,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
17367 {
17368 220 ret.setHopDir(d2);
17369 220 ret.setIlswim(true);
17370 220 }
17371 696 else ret.setIlswim(false);
17372 916 }
17373
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 25 times.
143 else if(d2==up)
17374 {
17375
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
50 if(!iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1) &&
17376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1) &&
17377
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
25 !_walkflag(x+7,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
17378
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 !_walkflag(x+8,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
17379 {
17380 25 ret.setHopDir(d2);
17381 25 ret.setIlswim(true);
17382 25 }
17383 else ret.setIlswim(false);
17384 25 }
17385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
118 else if(d2==down)
17386 {
17387
4/4
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 90 times.
146 if(!iswaterex(MAPCOMBO(x+7,y+16), currmap, currscr, -1, x+7,y+16) &&
17388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16) &&
17389
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 28 times.
28 !_walkflag(x+7,y+16,1,SWITCHBLOCK_STATE) &&
17390
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
28 !_walkflag(x+8,y+16,1,SWITCHBLOCK_STATE))
17391 {
17392 28 ret.setHopDir(d2);
17393 28 ret.setIlswim(true);
17394 28 }
17395 90 else ret.setIlswim(false);
17396 118 }
17397 1179 }
17398
17399
2/4
✓ Branch 0 taken 7581 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7581 times.
7581 if(wx<0||wy<0);
17400
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 6561 times.
7581 else if(wx>248);
17401
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6561 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6561 else if(wx>240&&cnt==2);
17402
2/2
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 6400 times.
6561 else if(wy>168);
17403
3/4
✓ Branch 0 taken 6106 times.
✓ Branch 1 taken 294 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6106 times.
6400 else if(get_bit(quest_rules, qr_DROWN) && !ilswim);
17404 //if(iswaterex(MAPCOMBO(wx,wy)) && iswaterex(MAPCOMBO(wx,wy)))
17405
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 276 times.
294 else if(iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy)) //!DIMI: weird duplicate function here before. Was water bugged this whole time, or was it just an unneccessary duplicate?
17406 {
17407 18 ret.setUnwalkable(false);
17408 18 return ret;
17409 }
17410 else
17411 {
17412 276 ret.setUnwalkable(true);
17413 276 return ret;
17414 }
17415 }
17416 8196 }
17417 else
17418 {
17419 104294 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
17420 104294 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Is x + 8 intentional???
17421
17422
8/8
✓ Branch 0 taken 99151 times.
✓ Branch 1 taken 5143 times.
✓ Branch 2 taken 96956 times.
✓ Branch 3 taken 2195 times.
✓ Branch 4 taken 5143 times.
✓ Branch 5 taken 2195 times.
✓ Branch 6 taken 4523 times.
✓ Branch 7 taken 620 times.
104294 if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
17423 {
17424 101479 ret.setUnwalkable(false);
17425 101479 return ret;
17426 }
17427 }
17428 11011 }
17429
2/2
✓ Branch 0 taken 130481 times.
✓ Branch 1 taken 7706447 times.
7836928 else if(ladderx+laddery) // ladder is being used
17430 {
17431
7/10
✓ Branch 0 taken 5960 times.
✓ Branch 1 taken 124521 times.
✓ Branch 2 taken 5907 times.
✓ Branch 3 taken 53 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 53 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 53 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 53 times.
130481 int32_t lx = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wx) : x;
17432
7/10
✓ Branch 0 taken 5960 times.
✓ Branch 1 taken 124521 times.
✓ Branch 2 taken 5907 times.
✓ Branch 3 taken 53 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 53 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 53 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 53 times.
130481 int32_t ly = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wy) : y;
17433
17434
3/4
✓ Branch 0 taken 130382 times.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 130382 times.
130481 if((diagonalMovement||NO_GRIDLOCK))
17435 {
17436
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(ladderdir==up)
17437 {
17438 if(abs(ly-(laddery+8))<=8) // ly is between laddery (laddery+8-8) and laddery+16 (laddery+8+8)
17439 {
17440 bool temp = false;
17441
17442 if(!(abs(lx-(ladderx+8))<=8))
17443 temp = true;
17444
17445 if(cnt==2)
17446 if(!(abs((lx+8)-(ladderx+8))<=8))
17447 temp=true;
17448
17449 if(!temp)
17450 {
17451 ret.setUnwalkable(false);
17452 return ret;
17453 }
17454
17455 if(current_item_power(itype_ladder)<2 && (d2==left || d2==right) && !isSideViewHero())
17456 {
17457 ret.setUnwalkable(true);
17458 return ret;
17459 }
17460 }
17461 }
17462 else
17463 {
17464
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 48 times.
99 if(abs(lx-(ladderx+8))<=8)
17465 {
17466
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 37 times.
48 if(abs(ly-(laddery+(bigHitbox?8:12)))<=(bigHitbox?8:4))
17467 {
17468 11 ret.setUnwalkable(false);
17469 11 return ret;
17470 }
17471
17472
4/6
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
37 if(current_item_power(itype_ladder)<2 && (d2==up || d2==down))
17473 {
17474 13 ret.setUnwalkable(true);
17475 13 return ret;
17476 }
17477
17478
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if((abs(ly-laddery+8)<=8) && d2<=down)
17479 {
17480 ret.setUnwalkable(false);
17481 return ret;
17482 }
17483 24 }
17484 }
17485 75 } // diagonalMovement
17486 else
17487 {
17488
2/2
✓ Branch 0 taken 81915 times.
✓ Branch 1 taken 48467 times.
130382 if((d2&2)==ladderdir) // same direction
17489 {
17490
3/3
✓ Branch 0 taken 4498 times.
✓ Branch 1 taken 73195 times.
✓ Branch 2 taken 4222 times.
81915 switch(d2)
17491 {
17492 case up:
17493
2/2
✓ Branch 0 taken 2866 times.
✓ Branch 1 taken 1356 times.
4222 if(y.getInt()<=laddery)
17494 {
17495
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2866 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2866 times.
✓ Branch 4 taken 197 times.
✓ Branch 5 taken 2669 times.
5535 ret.setUnwalkable(_walkflag(ladderx,laddery-8,1,SWITCHBLOCK_STATE) ||
17496
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2669 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2669 times.
2669 _walkflag(ladderx+8,laddery-8,1,SWITCHBLOCK_STATE));
17497 2866 return ret;
17498
17499 }
17500
17501 [[fallthrough]];
17502 case down:
17503
2/2
✓ Branch 0 taken 3151 times.
✓ Branch 1 taken 2703 times.
5854 if((wy&0xF0)==laddery)
17504 {
17505 3151 ret.setUnwalkable(false);
17506 3151 return ret;
17507 }
17508
17509 2703 break;
17510
17511 default:
17512
2/2
✓ Branch 0 taken 29513 times.
✓ Branch 1 taken 43682 times.
73195 if((wx&0xF0)==ladderx)
17513 {
17514 29513 ret.setUnwalkable(false);
17515 29513 return ret;
17516 }
17517 43682 }
17518
17519
2/2
✓ Branch 0 taken 2703 times.
✓ Branch 1 taken 43682 times.
46385 if(d2<=down)
17520 {
17521
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 2703 times.
✓ Branch 2 taken 2703 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 2609 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2609 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2609 times.
2703 ret.setUnwalkable(_walkflag(ladderx,wy,1,SWITCHBLOCK_STATE) || _walkflag(ladderx+8,wy,1,SWITCHBLOCK_STATE));
17522 2703 return ret;
17523 }
17524
17525
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 43682 times.
✓ Branch 2 taken 43682 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6894 times.
✓ Branch 5 taken 36788 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 36788 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 36788 times.
43682 ret.setUnwalkable(_walkflag((wx&0xF0),wy,1,SWITCHBLOCK_STATE) || _walkflag((wx&0xF0)+8,wy,1,SWITCHBLOCK_STATE));
17526 43682 return ret;
17527 }
17528
17529 // different dir
17530
3/8
✓ Branch 0 taken 48038 times.
✓ Branch 1 taken 429 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48038 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
48467 if(current_item_power(itype_ladder)<2 && !(isSideViewHero() && (d2==left || d2==right)))
17531 {
17532 48038 ret.setUnwalkable(true);
17533 48038 return ret;
17534 }
17535
17536
5/6
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 372 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 352 times.
✓ Branch 5 taken 20 times.
429 if(wy>=laddery && wy<=laddery+16 && d2<=down)
17537 {
17538 20 ret.setUnwalkable(false);
17539 20 return ret;
17540 }
17541 }
17542 484 }
17543
6/6
✓ Branch 0 taken 6616059 times.
✓ Branch 1 taken 1090388 times.
✓ Branch 2 taken 6558727 times.
✓ Branch 3 taken 57332 times.
✓ Branch 4 taken 1303973 times.
✓ Branch 5 taken 5254754 times.
7706447 else if(wf || isSideViewHero() || get_bit(quest_rules, qr_DROWN))
17544 {
17545 // see if it's a good spot for the ladder or for swimming
17546
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2451693 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2451693 times.
2451693 bool unwalkablex = _walkflag(wx,wy,1,SWITCHBLOCK_STATE); //will be used later for the ladder -DD
17547
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2451693 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2451693 times.
2451693 bool unwalkablex8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE);
17548
17549
2/2
✓ Branch 0 taken 1726267 times.
✓ Branch 1 taken 725426 times.
2451693 if(get_bit(quest_rules, qr_DROWN))
17550 {
17551 // Drowning changes the following attributes:
17552 // * Dangerous water is also walkable, so ignore the previous
17553 // definitions of unwalkablex and unwalkablex8.
17554 // * Instead, prevent the ladder from being used in the
17555 // one frame where Hero has landed on water before drowning.
17556 1726267 unwalkablex = unwalkablex8 = !iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11);
17557 1726267 }
17558
17559 // check if he can swim
17560
5/6
✓ Branch 0 taken 649708 times.
✓ Branch 1 taken 1801985 times.
✓ Branch 2 taken 649492 times.
✓ Branch 3 taken 216 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 649492 times.
2451693 if(current_item(itype_flippers) && z==0 && fakez==0)
17561 {
17562 649492 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
17563 649492 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Still not sure if this should be x + 8...
17564
2/6
✓ Branch 0 taken 649492 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 649492 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
649492 if (current_item(itype_flippers) >= combobuf[wtrx8].attribytes[0] && (!(combobuf[wtrx8].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))) //Don't swim if the water's required level is too high! -Dimi
17565 {
17566 //ladder ignores water combos that are now walkable thanks to flippers -DD
17567
2/2
✓ Branch 0 taken 1106 times.
✓ Branch 1 taken 648386 times.
649492 unwalkablex = unwalkablex && (!wtrx);
17568
2/2
✓ Branch 0 taken 77311 times.
✓ Branch 1 taken 572181 times.
649492 unwalkablex8 = unwalkablex8 && (!wtrx8);
17569
17570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 649492 times.
649492 if(landswim >= 22)
17571 {
17572 ret.setHopClk(2);
17573 ret.setUnwalkable(false);
17574 return ret;
17575 }
17576
8/8
✓ Branch 0 taken 551335 times.
✓ Branch 1 taken 98157 times.
✓ Branch 2 taken 2500 times.
✓ Branch 3 taken 548835 times.
✓ Branch 4 taken 98157 times.
✓ Branch 5 taken 548835 times.
✓ Branch 6 taken 268 times.
✓ Branch 7 taken 97889 times.
649492 else if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
17577 {
17578
3/4
✓ Branch 0 taken 2307 times.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2307 times.
2768 if(!(diagonalMovement||NO_GRIDLOCK))
17579 {
17580 2307 ret.setHopClk(2);
17581
17582
2/4
✓ Branch 0 taken 2307 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2307 times.
2307 if(charging || spins>5)
17583 {
17584 //if Hero is charging, he might be facing the wrong direction (we want him to
17585 //hop into the water, not in the facing direction)
17586 ret.setDir(d2);
17587 //moreover Hero can't charge in the water -DD
17588 ret.setChargeAttack();
17589 }
17590
17591 2307 ret.setUnwalkable(false);
17592 2307 return ret;
17593 }
17594
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 336 times.
461 else if(dir==d2)
17595 {
17596 336 ret.setIlswim(true);
17597 336 ladderx = 0;
17598 336 laddery = 0;
17599 336 }
17600 461 }
17601 647185 }
17602 647185 }
17603
17604 // check if he can use the ladder
17605 // "Allow Ladder Anywhere" is toggled by fLADDER
17606
2/2
✓ Branch 0 taken 1767538 times.
✓ Branch 1 taken 681848 times.
2449386 if(can_deploy_ladder())
17607 // laddersetup
17608 {
17609 // Check if there's water to use the ladder over
17610 681848 bool wtrx = (iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy) != 0);
17611 681848 bool wtrx8 = (iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy) != 0);
17612 681848 int32_t ldrid = current_item_id(itype_ladder);
17613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 681848 times.
681848 bool ladderpits = ldrid > -1 && (itemsbuf[ldrid].flags&ITEM_FLAG1);
17614
17615
4/4
✓ Branch 0 taken 675547 times.
✓ Branch 1 taken 6301 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 675530 times.
681848 if(wtrx || wtrx8)
17616 {
17617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6318 times.
6318 if(isSideViewHero())
17618 {
17619 wtrx = !_walkflag(wx, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
17620 wtrx8 = !_walkflag(wx+8, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx+8, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
17621 }
17622 // * walk on half-water using the ladder instead of using flippers.
17623 // * otherwise, walk on ladder(+hookshot) combos.
17624
3/8
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 5931 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 387 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6318 else if(wtrx==wtrx8 && (isstepable(MAPCOMBO(wx, wy)) || isstepable(MAPCOMBO(wx+8,wy)) || wtrx==true))
17625 {
17626
1/2
✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
387 if(!get_bit(quest_rules, qr_OLD_210_WATER))
17627 {
17628 //if Hero could swim on a tile instead of using the ladder,
17629 //refuse to use the ladder to step over that tile. -DD
17630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 wtrx = isstepable(MAPCOMBO(wx, wy)) && unwalkablex;
17631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 wtrx8 = isstepable(MAPCOMBO(wx+8,wy)) && unwalkablex8;
17632 387 }
17633 387 }
17634 6318 }
17635 else
17636 {
17637 // No water; check other things
17638
17639 //Check pits
17640
2/2
✓ Branch 0 taken 674503 times.
✓ Branch 1 taken 1027 times.
675530 if(ladderpits)
17641 {
17642 1027 int32_t pit_cmb = getpitfall(wx,wy);
17643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 wtrx = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
17644 1027 pit_cmb = getpitfall(x+8,wy);
17645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 wtrx8 = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
17646 1027 }
17647
4/6
✓ Branch 0 taken 1027 times.
✓ Branch 1 taken 674503 times.
✓ Branch 2 taken 1027 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1027 times.
✗ Branch 5 not taken.
675530 if(!ladderpits || (!(wtrx || wtrx8) || isSideViewHero())) //If no pit, check ladder combos
17648 {
17649 675530 int32_t combo=combobuf[MAPCOMBO(wx, wy)].type;
17650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 675530 times.
675530 wtrx=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
17651 675530 combo=combobuf[MAPCOMBO(wx+8, wy)].type;
17652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 675530 times.
675530 wtrx8=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
17653 675530 }
17654 }
17655
17656
2/2
✓ Branch 0 taken 1363696 times.
✓ Branch 1 taken 681848 times.
2045544 for (int32_t i = 0; i <= 1; ++i)
17657 {
17658
2/2
✓ Branch 0 taken 1092716 times.
✓ Branch 1 taken 270980 times.
1363696 if(tmpscr2[i].valid!=0)
17659 {
17660
2/2
✓ Branch 0 taken 268926 times.
✓ Branch 1 taken 2054 times.
270980 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
17661 {
17662
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268926 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268926 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && !_walkflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
17663
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268926 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268926 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && !_walkflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
17664 268926 }
17665 else
17666 {
17667
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2054 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2054 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && _effectflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
17668
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2054 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2054 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && _effectflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
17669 }
17670 270980 }
17671 1363696 }
17672
2/2
✓ Branch 0 taken 533010 times.
✓ Branch 1 taken 148838 times.
681848 bool walkwater = (get_bit(quest_rules, qr_DROWN) && !iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy));
17673
17674
3/4
✓ Branch 0 taken 672970 times.
✓ Branch 1 taken 8878 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 672970 times.
681848 if((diagonalMovement||NO_GRIDLOCK))
17675 {
17676
2/2
✓ Branch 0 taken 1232 times.
✓ Branch 1 taken 7646 times.
8878 if(d2==dir)
17677 {
17678 7646 int32_t c = walkwater ? 0:8;
17679 7646 int32_t b = walkwater ? 8:0;
17680
17681
2/2
✓ Branch 0 taken 6401 times.
✓ Branch 1 taken 1245 times.
7646 if(d2>=left)
17682 {
17683 // If the difference between wy and y is small enough
17684
4/4
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 5129 times.
✓ Branch 2 taken 6400 times.
✓ Branch 3 taken 1 times.
6401 if(abs((wy)-(int32_t(y+c)))<=(b) && wtrx)
17685 {
17686 // Don't activate the ladder if it would be entirely
17687 // over water and Hero has the flippers. This isn't
17688 // a good way to do this, but it's too risky
17689 // to make big changes to this stuff.
17690 1 bool deployLadder=true;
17691 1 int32_t lx=wx&0xF0;
17692
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
1 if(current_item(itype_flippers) && current_item(itype_flippers) >= combobuf[iswaterex(MAPCOMBO(lx+8, y+8), currmap, currscr, -1, lx+8, y+8)].attribytes[0] && z==0 && fakez==0)
17693 {
17694 if(iswaterex(MAPCOMBO(lx, y), currmap, currscr, -1, lx, y) &&
17695 iswaterex(MAPCOMBO(lx+15, y), currmap, currscr, -1, lx+15, y) &&
17696 iswaterex(MAPCOMBO(lx, y+15), currmap, currscr, -1, lx, y+15) &&
17697 iswaterex(MAPCOMBO(lx+15, y+15), currmap, currscr, -1, lx+15, y+15))
17698 deployLadder=false;
17699 }
17700
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(deployLadder)
17701 {
17702 1 ladderx = wx&0xF0;
17703 1 laddery = y;
17704 1 ladderdir = left;
17705 1 ladderstart = d2;
17706 1 ret.setUnwalkable(laddery!=y.getInt());
17707 1 return ret;
17708 }
17709 }
17710 6400 }
17711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1245 times.
1245 else if(d2<=down)
17712 {
17713 // If the difference between wx and x is small enough
17714
3/4
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 755 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1245 times.
1245 if(abs((wx)-(int32_t(x+c)))<=(b) && wtrx)
17715 {
17716 ladderx = x;
17717 laddery = wy&0xF0;
17718 ladderdir = up;
17719 ladderstart = d2;
17720 ret.setUnwalkable(ladderx!=x.getInt());
17721 return ret;
17722 }
17723
17724
2/2
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 755 times.
1245 if(cnt==2)
17725 {
17726
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 755 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 755 times.
755 if(abs((wx+8)-(int32_t(x+c)))<=(b) && wtrx8)
17727 {
17728 ladderx = x;
17729 laddery = wy&0xF0;
17730 ladderdir = up;
17731 ladderstart = d2;
17732 ret.setUnwalkable(ladderx!=x.getInt());
17733 return ret;
17734 }
17735 755 }
17736 1245 }
17737 7645 }
17738 8877 }
17739 else
17740 {
17741
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 672970 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 672970 times.
✓ Branch 4 taken 106753 times.
✓ Branch 5 taken 566217 times.
672970 bool flgx = _walkflag(wx,wy,1,SWITCHBLOCK_STATE) && !wtrx; // Solid, and not steppable
17742
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 672970 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 672970 times.
✓ Branch 4 taken 633061 times.
✓ Branch 5 taken 39909 times.
672970 bool flgx8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE) && !wtrx8; // Solid, and not steppable
17743
17744
2/2
✓ Branch 0 taken 619225 times.
✓ Branch 1 taken 53745 times.
672987 if((d2>=left && wtrx)
17745 // Deploy the ladder vertically even if Hero is only half on water.
17746
8/8
✓ Branch 0 taken 7392 times.
✓ Branch 1 taken 611833 times.
✓ Branch 2 taken 53745 times.
✓ Branch 3 taken 611833 times.
✓ Branch 4 taken 450 times.
✓ Branch 5 taken 53295 times.
✓ Branch 6 taken 17 times.
✓ Branch 7 taken 53728 times.
672970 || (d2<=down && ((wtrx && !flgx8) || (wtrx8 && !flgx))))
17747 {
17748
4/4
✓ Branch 0 taken 7211 times.
✓ Branch 1 taken 181 times.
✓ Branch 2 taken 286 times.
✓ Branch 3 taken 6925 times.
7392 if(((y.getInt()+15) < wy) || ((y.getInt()+8) > wy))
17749 467 ladderdir = up;
17750 else
17751 6925 ladderdir = left;
17752
17753
2/2
✓ Branch 0 taken 6925 times.
✓ Branch 1 taken 467 times.
7392 if(ladderdir==up)
17754 {
17755 467 ladderx = x.getInt()&0xF8;
17756 467 laddery = wy&0xF0;
17757 467 }
17758 else
17759 {
17760 6925 ladderx = wx&0xF0;
17761 6925 laddery = y.getInt()&0xF8;
17762 }
17763
17764 7392 ret.setUnwalkable(false);
17765 7392 return ret;
17766 }
17767 }
17768 674455 }
17769 2441993 }
17770
17771 7708242 ret.setUnwalkable(wf);
17772 7708242 return ret;
17773 8067485 }
17774
17775 // Only checks for moving blocks. Apparently this is a thing we need.
17776 820760 HeroClass::WalkflagInfo HeroClass::walkflagMBlock(int32_t wx,int32_t wy)
17777 {
17778 820760 HeroClass::WalkflagInfo ret;
17779
2/2
✓ Branch 0 taken 6584 times.
✓ Branch 1 taken 814176 times.
820760 if (!blockmoving) //Without this, weird swimming behaviors happen.
17780 {
17781 814176 ret.setFlags(~1);
17782 814176 ret.setHopDir(-1);
17783 814176 }
17784
2/2
✓ Branch 0 taken 2636 times.
✓ Branch 1 taken 818124 times.
820760 if(toogam) return ret;
17785
2/2
✓ Branch 0 taken 811540 times.
✓ Branch 1 taken 6584 times.
818124 if (blockmoving)
17786 6584 ret.setUnwalkable(mblock2.hit(wx,wy,0,1,1,1));
17787
2/2
✓ Branch 0 taken 817792 times.
✓ Branch 1 taken 332 times.
818124 if (collide_object(wx, wy,1, 1))
17788 332 ret.setUnwalkable(true);
17789 818124 return ret;
17790 820760 }
17791
17792 3360072 bool HeroClass::checksoliddamage()
17793 {
17794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3360072 times.
3360072 if(toogam) return false;
17795
17796
2/4
✓ Branch 0 taken 3360072 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3360072 times.
3360072 if(z!=0||fakez!=0) return false;
17797 3360072 int32_t bx = x.getInt();
17798 3360072 int32_t by = y.getInt();
17799 3360072 int32_t initk = 0;
17800
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 823821 times.
✓ Branch 2 taken 661832 times.
✓ Branch 3 taken 913504 times.
✓ Branch 4 taken 960915 times.
3360072 switch(dir)
17801 {
17802 case up:
17803
17804 823821 by-=bigHitbox ? 4 : -4;
17805
17806
1/2
✓ Branch 0 taken 823821 times.
✗ Branch 1 not taken.
823821 if(by<0)
17807 {
17808 return false;
17809 }
17810 823821 break;
17811
17812 case down:
17813
17814 661832 by+=20;
17815
2/2
✓ Branch 0 taken 4518 times.
✓ Branch 1 taken 657314 times.
661832 if(by>175)
17816 {
17817 4518 return false;
17818 }
17819
17820 657314 break;
17821
17822 case left:
17823 913504 bx-=4;
17824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 913504 times.
913504 if (!bigHitbox)
17825 {
17826 913504 by+=8;
17827 913504 initk = 1;
17828 913504 }
17829
2/2
✓ Branch 0 taken 909438 times.
✓ Branch 1 taken 4066 times.
913504 if(bx<0)
17830 {
17831 4066 return false;
17832 }
17833
17834 909438 break;
17835
17836 case right:
17837
17838 960915 bx+=20;
17839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 960915 times.
960915 if (!bigHitbox)
17840 {
17841 960915 by+=8;
17842 960915 initk = 1;
17843 960915 }
17844
2/2
✓ Branch 0 taken 5363 times.
✓ Branch 1 taken 955552 times.
960915 if(bx>255)
17845 {
17846 5363 return false;
17847 }
17848
17849 955552 break;
17850 }
17851 3346125 newcombo const& cmb = combobuf[MAPCOMBO(bx,by)];
17852 3346125 int32_t t = cmb.type;
17853
1/2
✓ Branch 0 taken 3346125 times.
✗ Branch 1 not taken.
3346125 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
17854 t = cNONE;
17855 3346125 int32_t initbx = bx;
17856 3346125 int32_t initby = by;
17857
17858 // Unlike push blocks, damage combos should be tested on layers 2 and under
17859
2/2
✓ Branch 0 taken 6724041 times.
✓ Branch 1 taken 3346114 times.
10070155 for(int32_t i=(get_bit(quest_rules,qr_DMGCOMBOLAYERFIX) ? 2 : 0); i>=0; i--)
17860 {
17861 6724041 bx = initbx;
17862 6724041 by = initby;
17863
2/2
✓ Branch 0 taken 16467443 times.
✓ Branch 1 taken 6724030 times.
23191473 for (int32_t k = initk; k <= 2; k++)
17864 {
17865 16467443 newcombo const& cmb = combobuf[FFCore.tempScreens[i]->data[COMBOPOS(bx,by)]];
17866 16467443 t = cmb.type;
17867
1/2
✓ Branch 0 taken 16467443 times.
✗ Branch 1 not taken.
16467443 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
17868 t = cNONE;
17869 // Solid damage combos use pushing>0, hence the code is here.
17870
10/10
✓ Branch 0 taken 291451 times.
✓ Branch 1 taken 16175992 times.
✓ Branch 2 taken 92953 times.
✓ Branch 3 taken 198498 times.
✓ Branch 4 taken 87274 times.
✓ Branch 5 taken 5679 times.
✓ Branch 6 taken 1683 times.
✓ Branch 7 taken 85591 times.
✓ Branch 8 taken 18 times.
✓ Branch 9 taken 1665 times.
16467443 if (!get_bit(quest_rules, qr_LESS_AWFUL_SIDESPIKES) || !isSideViewHero() || (dir != down && (dir != up || getOnSideviewLadder())))
17871 {
17872
14/18
✓ Branch 0 taken 16451845 times.
✓ Branch 1 taken 8254 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8254 times.
✓ Branch 4 taken 8254 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1091 times.
✓ Branch 7 taken 7163 times.
✓ Branch 8 taken 114 times.
✓ Branch 9 taken 977 times.
✓ Branch 10 taken 60 times.
✓ Branch 11 taken 54 times.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 60 times.
✓ Branch 16 taken 16460039 times.
✓ Branch 17 taken 60 times.
16460099 if(combo_class_buf[t].modify_hp_amount && _walkflag(bx,by,1,SWITCHBLOCK_STATE) && pushing>0 && hclk<1 && action!=casting && action != sideswimcasting && !get_bit(quest_rules, qr_NOSOLIDDAMAGECOMBOS))
17873 {
17874 // Bite Hero
17875
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 6 times.
60 if (checkdamagecombos(bx, bx, by, by, i-1, true)) return true;
17876 54 }
17877 16460093 }
17878
3/4
✓ Branch 0 taken 105784 times.
✓ Branch 1 taken 16361653 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99520 times.
16566957 if(isSideViewHero() && // Check for sideview damage combos
17879
3/4
✓ Branch 0 taken 99520 times.
✓ Branch 1 taken 6264 times.
✓ Branch 2 taken 99520 times.
✗ Branch 3 not taken.
105784 hclk<1 && action!=casting && action!=sideswimcasting) // ... but only if Hero could be hurt
17880 {
17881
2/2
✓ Branch 0 taken 87637 times.
✓ Branch 1 taken 11883 times.
99520 if (get_bit(quest_rules, qr_LESS_AWFUL_SIDESPIKES))
17882 {
17883
4/6
✓ Branch 0 taken 87637 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 87619 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
87637 if (on_sideview_solid_oldpos(x,y,old_x,old_y) && (!getOnSideviewLadder() || DrunkDown()))
17884 {
17885
4/4
✓ Branch 0 taken 87610 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 87614 times.
✓ Branch 3 taken 5 times.
87619 if(checkdamagecombos(x+4, x+4, y+16, y+18, i-1, false, false) && checkdamagecombos(x+12, x+12, y+16, y+18, i-1, false, false))
17886 {
17887
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (checkdamagecombos(x+4, x+12, y+16, y+18, i-1, false, true)) return true;
17888 }
17889 87614 }
17890
1/2
✓ Branch 0 taken 87632 times.
✗ Branch 1 not taken.
87632 if (checkdamagecombos(x+4, x+12, y+8, y+15, i-1, false, true)) return true;
17891 87632 }
17892 else
17893 {
17894 //old 2.50.2-ish code for 2.50.0 sideview quests for er_OLDSIDEVIEWSPIKES
17895
1/2
✓ Branch 0 taken 11883 times.
✗ Branch 1 not taken.
11883 if ( get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES ) )
17896 {
17897
1/2
✓ Branch 0 taken 11883 times.
✗ Branch 1 not taken.
23766 if (checkdamagecombos(x+8-(zfix)(tmpscr->csensitive),
17898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11883 times.
11883 x+8+(zc_max(tmpscr->csensitive-1,0)),
17899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11883 times.
11883 y+17-(get_bit(quest_rules,qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2),
17900
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11883 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11883 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11883 y+17+zc_max((get_bit(quest_rules,qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2)-1,0), i-1, true))
17901 return true;
17902 11883 }
17903 else //2.50.1 and later
17904 {
17905 if(checkdamagecombos(x+4, x+12, y+16, y+24))
17906 return true;
17907 }
17908 }
17909
17910 99515 }
17911
2/2
✓ Branch 0 taken 9058116 times.
✓ Branch 1 taken 7409316 times.
16467432 if (dir < left) bx += (k % 2) ? 7 : 8;
17912 7409316 else by += (k % 2) ? 7 : 8;
17913 16467432 }
17914 6724030 }
17915 3346114 return false;
17916 3360072 }
17917 3391281 void HeroClass::checkpushblock()
17918 {
17919
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 3377875 times.
3391281 if(toogam) return;
17920
17921
3/4
✓ Branch 0 taken 3374606 times.
✓ Branch 1 taken 3269 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3374606 times.
3377875 if(z!=0||fakez!=0) return;
17922
17923 // Return early in some cases..
17924 3374606 bool earlyReturn=false;
17925
17926
4/4
✓ Branch 0 taken 3106581 times.
✓ Branch 1 taken 268025 times.
✓ Branch 2 taken 3185489 times.
✓ Branch 3 taken 189117 times.
3374606 if(!(diagonalMovement||NO_GRIDLOCK) || dir==left)
17927
2/2
✓ Branch 0 taken 1140104 times.
✓ Branch 1 taken 2045385 times.
3185489 if(x.getInt()&15) earlyReturn=true;
17928
17929 // if(y<16) return;
17930
4/4
✓ Branch 0 taken 31654 times.
✓ Branch 1 taken 3342952 times.
✓ Branch 2 taken 17120 times.
✓ Branch 3 taken 14534 times.
3374606 if(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y)) return;
17931
17932 3360072 int32_t bx = x.getInt()&0xF0;
17933 3360072 int32_t by = (y.getInt()&0xF0);
17934
17935
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 823821 times.
✓ Branch 2 taken 661832 times.
✓ Branch 3 taken 913504 times.
✓ Branch 4 taken 960915 times.
3360072 switch(dir)
17936 {
17937 case up:
17938
2/2
✓ Branch 0 taken 24624 times.
✓ Branch 1 taken 799197 times.
823821 if(y<16)
17939 {
17940 24624 earlyReturn=true;
17941 24624 break;
17942 }
17943
17944
3/4
✓ Branch 0 taken 123779 times.
✓ Branch 1 taken 675418 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 123779 times.
799197 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
17945
17946
2/2
✓ Branch 0 taken 458194 times.
✓ Branch 1 taken 341003 times.
799197 if((int32_t)x&8) bx+=16;
17947
17948 799197 break;
17949
17950 case down:
17951
2/2
✓ Branch 0 taken 32270 times.
✓ Branch 1 taken 629562 times.
661832 if(y>128)
17952 {
17953 32270 earlyReturn=true;
17954 32270 break;
17955 }
17956 else
17957 {
17958 629562 by+=16;
17959
17960
2/2
✓ Branch 0 taken 395796 times.
✓ Branch 1 taken 233766 times.
629562 if((int32_t)x&8) bx+=16;
17961 }
17962
17963 629562 break;
17964
17965 case left:
17966
2/2
✓ Branch 0 taken 35316 times.
✓ Branch 1 taken 878188 times.
913504 if(x<32)
17967 {
17968 35316 earlyReturn=true;
17969 35316 break;
17970 }
17971 else
17972 {
17973 878188 bx-=16;
17974
17975
2/2
✓ Branch 0 taken 526211 times.
✓ Branch 1 taken 351977 times.
878188 if(y.getInt()&8)
17976 {
17977 351977 by+=16;
17978 351977 }
17979 }
17980
17981 878188 break;
17982
17983 case right:
17984
2/2
✓ Branch 0 taken 38485 times.
✓ Branch 1 taken 922430 times.
960915 if(x>208)
17985 {
17986 38485 earlyReturn=true;
17987 38485 break;
17988 }
17989 else
17990 {
17991 922430 bx+=16;
17992
17993
2/2
✓ Branch 0 taken 563675 times.
✓ Branch 1 taken 358755 times.
922430 if(y.getInt()&8)
17994 {
17995 358755 by+=16;
17996 358755 }
17997 }
17998
17999 922430 break;
18000 }
18001
18002
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 3360061 times.
3360072 if (checksoliddamage()) return;
18003
18004
2/2
✓ Branch 0 taken 2082668 times.
✓ Branch 1 taken 1277393 times.
3360061 if(earlyReturn)
18005 2082668 return;
18006
18007 1277393 int32_t itemid=current_item_id(itype_bracelet);
18008 1277393 size_t combopos = (by&0xF0)+(bx>>4);
18009
2/2
✓ Branch 0 taken 375799 times.
✓ Branch 1 taken 901594 times.
1277393 bool limitedpush = (itemid>=0 && itemsbuf[itemid].flags & ITEM_FLAG1);
18010
2/2
✓ Branch 0 taken 901594 times.
✓ Branch 1 taken 375799 times.
1277393 itemdata const* glove = itemid < 0 ? NULL : &itemsbuf[itemid];
18011
2/2
✓ Branch 0 taken 600748 times.
✓ Branch 1 taken 2462027 times.
3062775 for(int lyr = 2; lyr > -1; --lyr) //Top-down, in case of stacked push blocks
18012 {
18013
4/4
✓ Branch 0 taken 873072 times.
✓ Branch 1 taken 1588955 times.
✓ Branch 2 taken 190965 times.
✓ Branch 3 taken 682107 times.
2462027 if(get_bit(quest_rules,qr_HESITANTPUSHBLOCKS)&&(pushing<4)) break;
18014
4/4
✓ Branch 0 taken 1190572 times.
✓ Branch 1 taken 589348 times.
✓ Branch 2 taken 1183430 times.
✓ Branch 3 taken 7142 times.
1779920 if(lyr && !get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
18015 1183430 continue;
18016 596490 mapscr* m = FFCore.tempScreens[lyr];
18017 596490 int32_t f = MAPFLAG2(lyr-1,bx,by);
18018 596490 int32_t f2 = MAPCOMBOFLAG2(lyr-1,bx,by);
18019 596490 int32_t t = combobuf[MAPCOMBOL(lyr,bx,by)].type;
18020
2/2
✓ Branch 0 taken 1204 times.
✓ Branch 1 taken 595286 times.
596490 if (lyr == 0) t = combobuf[MAPCOMBO(bx,by)].type;
18021
18022
8/8
✓ Branch 0 taken 558908 times.
✓ Branch 1 taken 37582 times.
✓ Branch 2 taken 556149 times.
✓ Branch 3 taken 2759 times.
✓ Branch 4 taken 9148 times.
✓ Branch 5 taken 512178 times.
✓ Branch 6 taken 552365 times.
✓ Branch 7 taken 561513 times.
596490 if((t==cPUSH_WAIT || t==cPUSH_HW || t==cPUSH_HW2) && (pushing<16 || hasMainGuy())) continue;
18023
18024
8/8
✓ Branch 0 taken 560973 times.
✓ Branch 1 taken 540 times.
✓ Branch 2 taken 558605 times.
✓ Branch 3 taken 2368 times.
✓ Branch 4 taken 558300 times.
✓ Branch 5 taken 305 times.
✓ Branch 6 taken 695 times.
✓ Branch 7 taken 562580 times.
565607 if((t==cPUSH_HW || t==cPUSH_HEAVY || t==cPUSH_HEAVY2 || t==cPUSH_HW2)
18025
8/8
✓ Branch 0 taken 881 times.
✓ Branch 1 taken 559181 times.
✓ Branch 2 taken 3694 times.
✓ Branch 3 taken 400 times.
✓ Branch 4 taken 305 times.
✓ Branch 5 taken 3389 times.
✓ Branch 6 taken 295 times.
✓ Branch 7 taken 3399 times.
564912 && (itemid<0 || glove->power<((t==cPUSH_HEAVY2 || t==cPUSH_HW2)?2:1) ||
18026
3/4
✓ Branch 0 taken 3393 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
4094 (limitedpush && usecounts[itemid] > zc_max(1, glove->misc3)))) continue;
18027
18028 562580 bool doit=false;
18029 562580 bool changeflag=false;
18030 562580 bool changecombo=false;
18031
18032
7/8
✓ Branch 0 taken 561453 times.
✓ Branch 1 taken 1127 times.
✓ Branch 2 taken 561453 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 679 times.
✓ Branch 5 taken 561901 times.
✓ Branch 6 taken 289 times.
✓ Branch 7 taken 560551 times.
1123420 if(((f==mfPUSHUD || f==mfPUSHUDNS|| f==mfPUSHUDINS) && dir<=down) ||
18033
3/4
✓ Branch 0 taken 561477 times.
✓ Branch 1 taken 424 times.
✓ Branch 2 taken 561477 times.
✗ Branch 3 not taken.
561901 ((f==mfPUSHLR || f==mfPUSHLRNS|| f==mfPUSHLRINS) && dir>=left) ||
18034
4/4
✓ Branch 0 taken 561496 times.
✓ Branch 1 taken 405 times.
✓ Branch 2 taken 561371 times.
✓ Branch 3 taken 125 times.
561901 ((f==mfPUSHU || f==mfPUSHUNS || f==mfPUSHUINS) && dir==up) ||
18035
3/4
✓ Branch 0 taken 561457 times.
✓ Branch 1 taken 444 times.
✓ Branch 2 taken 561457 times.
✗ Branch 3 not taken.
561901 ((f==mfPUSHD || f==mfPUSHDNS || f==mfPUSHDINS) && dir==down) ||
18036
3/4
✓ Branch 0 taken 561464 times.
✓ Branch 1 taken 437 times.
✓ Branch 2 taken 561464 times.
✗ Branch 3 not taken.
561901 ((f==mfPUSHL || f==mfPUSHLNS || f==mfPUSHLINS) && dir==left) ||
18037
3/4
✓ Branch 0 taken 561394 times.
✓ Branch 1 taken 507 times.
✓ Branch 2 taken 561394 times.
✗ Branch 3 not taken.
561901 ((f==mfPUSHR || f==mfPUSHRNS || f==mfPUSHRINS) && dir==right) ||
18038
2/2
✓ Branch 0 taken 560840 times.
✓ Branch 1 taken 47 times.
560887 f==mfPUSH4 || f==mfPUSH4NS || f==mfPUSH4INS)
18039 {
18040 1015 changeflag=true;
18041 1015 doit=true;
18042 1015 }
18043
18044
7/8
✓ Branch 0 taken 561546 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 561546 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 561556 times.
✓ Branch 6 taken 561545 times.
✓ Branch 7 taken 1 times.
1123102 if((((f2==mfPUSHUD || f2==mfPUSHUDNS|| f2==mfPUSHUDINS) && dir<=down) ||
18045
3/4
✓ Branch 0 taken 561546 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 561546 times.
✗ Branch 3 not taken.
561556 ((f2==mfPUSHLR || f2==mfPUSHLRNS|| f2==mfPUSHLRINS) && dir>=left) ||
18046
3/4
✓ Branch 0 taken 561546 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 561546 times.
✗ Branch 3 not taken.
561556 ((f2==mfPUSHU || f2==mfPUSHUNS || f2==mfPUSHUINS) && dir==up) ||
18047
3/4
✓ Branch 0 taken 561546 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 561546 times.
✗ Branch 3 not taken.
561556 ((f2==mfPUSHD || f2==mfPUSHDNS || f2==mfPUSHDINS) && dir==down) ||
18048
3/4
✓ Branch 0 taken 561546 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 561546 times.
✗ Branch 3 not taken.
561556 ((f2==mfPUSHL || f2==mfPUSHLNS || f2==mfPUSHLINS) && dir==left) ||
18049
3/4
✓ Branch 0 taken 561546 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 561546 times.
✗ Branch 3 not taken.
561556 ((f2==mfPUSHR || f2==mfPUSHRNS || f2==mfPUSHRINS) && dir==right) ||
18050
1/2
✓ Branch 0 taken 561536 times.
✗ Branch 1 not taken.
561546 f2==mfPUSH4 || f2==mfPUSH4NS || f2==mfPUSH4INS)&&(f!=mfPUSHED))
18051 {
18052 1 changecombo=true;
18053 1 doit=true;
18054 1 }
18055
18056
2/2
✓ Branch 0 taken 62074 times.
✓ Branch 1 taken 499472 times.
561546 if(get_bit(quest_rules,qr_SOLIDBLK))
18057 {
18058
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 11377 times.
✓ Branch 2 taken 12395 times.
✓ Branch 3 taken 17920 times.
✓ Branch 4 taken 20382 times.
62074 switch(dir)
18059 {
18060 case up:
18061
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 11377 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11377 times.
✓ Branch 4 taken 4630 times.
✓ Branch 5 taken 6747 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 6747 times.
✓ Branch 8 taken 4634 times.
✓ Branch 9 taken 6743 times.
11377 if(_walkflag(bx,by-8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE)) doit=false;
18062
18063 11377 break;
18064
18065 case down:
18066
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 12395 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12395 times.
✓ Branch 4 taken 4901 times.
✓ Branch 5 taken 7494 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 7494 times.
✓ Branch 8 taken 4905 times.
✓ Branch 9 taken 7490 times.
12395 if(_walkflag(bx,by+24,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE)) doit=false;
18067
18068 12395 break;
18069
18070 case left:
18071
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 17920 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17920 times.
✓ Branch 4 taken 7616 times.
✓ Branch 5 taken 10304 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 10304 times.
✓ Branch 8 taken 7622 times.
✓ Branch 9 taken 10298 times.
17920 if(_walkflag(bx-16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE)) doit=false;
18072
18073 17920 break;
18074
18075 case right:
18076
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 20382 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20382 times.
✓ Branch 4 taken 7722 times.
✓ Branch 5 taken 12660 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12660 times.
✓ Branch 8 taken 7732 times.
✓ Branch 9 taken 12650 times.
20382 if(_walkflag(bx+16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE)) doit=false;
18077
18078 20382 break;
18079 }
18080 62074 }
18081
18082
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 220047 times.
✓ Branch 2 taken 189846 times.
✓ Branch 3 taken 74917 times.
✓ Branch 4 taken 76736 times.
561546 switch(dir)
18083 {
18084 case up:
18085
3/4
✓ Branch 0 taken 219715 times.
✓ Branch 1 taken 332 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 219715 times.
220047 if((MAPFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS)) doit=false;
18086
18087 220047 break;
18088
18089 case down:
18090
3/4
✓ Branch 0 taken 189430 times.
✓ Branch 1 taken 416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 189430 times.
189846 if((MAPFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS)) doit=false;
18091
18092 189846 break;
18093
18094 case left:
18095
3/4
✓ Branch 0 taken 74835 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 74835 times.
74917 if((MAPFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS)) doit=false;
18096
18097 74917 break;
18098
18099 case right:
18100
3/4
✓ Branch 0 taken 76712 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76712 times.
76736 if((MAPFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS)) doit=false;
18101
18102 76736 break;
18103 }
18104
18105
2/2
✓ Branch 0 taken 561070 times.
✓ Branch 1 taken 476 times.
561546 if(doit)
18106 {
18107
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 7 times.
476 if(limitedpush)
18108 7 ++usecounts[itemid];
18109
18110 // for(int32_t i=0; i<1; i++)
18111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 476 times.
476 if(!blockmoving)
18112 {
18113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 476 times.
476 if(changeflag)
18114 {
18115 476 m->sflag[combopos]=0;
18116 476 }
18117
18118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 476 times.
476 if(mblock2.clk<=0)
18119 {
18120 476 mblock2.blockLayer = lyr;
18121 476 mblock2.push((zfix)bx,(zfix)by,dir,f);
18122
18123
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 475 times.
476 if(get_bit(quest_rules,qr_MORESOUNDS))
18124 1 sfx(WAV_ZN1PUSHBLOCK,(int32_t)x);
18125 476 }
18126 476 }
18127 476 break;
18128 }
18129 561070 }
18130 3397219 }
18131
18132 155 bool usekey()
18133 {
18134 155 int32_t itemid = current_item_id(itype_magickey);
18135
18136
3/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
155 if(itemid<0 ||
18137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 (itemsbuf[itemid].flags & ITEM_FLAG1 ? itemsbuf[itemid].power<dlevel
18138 : itemsbuf[itemid].power!=dlevel))
18139 {
18140
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 94 times.
125 if(game->lvlkeys[dlevel]!=0)
18141 {
18142 31 game->lvlkeys[dlevel]--;
18143 //run script for level key item
18144 31 int32_t key_item = 0; //current_item_id(itype_lkey); //not possible
18145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2635 times.
2635 for ( int32_t q = 0; q < MAXITEMS; ++q )
18146 {
18147
2/2
✓ Branch 0 taken 2604 times.
✓ Branch 1 taken 31 times.
2635 if ( itemsbuf[q].family == itype_lkey )
18148 {
18149 31 key_item = q; break;
18150 }
18151 2604 }
18152
18153
2/8
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
31 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18154 {
18155 ri = &(itemScriptData[key_item]);
18156 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18157 ri->Clear();
18158 item_doscript[key_item] = 1;
18159 itemscriptInitialised[key_item] = 0;
18160 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18161 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18162 }
18163 31 return true;
18164 }
18165 else
18166 {
18167
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 if(game->get_keys()==0)
18168 {
18169 30 return false;
18170 }
18171 else
18172 {
18173 //run script for key item
18174 64 int32_t key_item = 0; //current_item_id(itype_key); //not possible
18175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 640 times.
640 for ( int32_t q = 0; q < MAXITEMS; ++q )
18176 {
18177
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 64 times.
640 if ( itemsbuf[q].family == itype_key )
18178 {
18179 64 key_item = q; break;
18180 }
18181 576 }
18182 //zprint2("key_item is: %d\n",key_item);
18183 //zprint2("key_item script is: %d\n",itemsbuf[key_item].script);
18184
2/8
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
64 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18185 {
18186 ri = &(itemScriptData[key_item]);
18187 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18188 ri->Clear();
18189 item_doscript[key_item] = 1;
18190 itemscriptInitialised[key_item] = 0;
18191 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18192 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18193 }
18194 64 game->change_keys(-1);
18195 }
18196 }
18197 64 }
18198
18199 94 return true;
18200 155 }
18201
18202 bool canUseKey(int32_t num)
18203 {
18204 int32_t itemid = current_item_id(itype_magickey);
18205
18206 if(itemid<0 ||
18207 (itemsbuf[itemid].flags & ITEM_FLAG1 ? itemsbuf[itemid].power<dlevel
18208 : itemsbuf[itemid].power!=dlevel))
18209 {
18210 return game->lvlkeys[dlevel] + game->get_keys() >= num;
18211 }
18212
18213 return true;
18214 }
18215
18216 bool usekey(int32_t num)
18217 {
18218 if(!canUseKey(num)) return false;
18219 for(auto q = 0; q < num; ++q)
18220 {
18221 if(!usekey()) return false; //should never return false here, but, just to be safe....
18222 }
18223 return true;
18224 }
18225
18226
18227 454 bool islockeddoor(int32_t x, int32_t y, int32_t lock)
18228 {
18229 454 int32_t mc = (y&0xF0)+(x>>4);
18230
3/6
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 454 times.
✗ Branch 5 not taken.
908 bool ret = (((mc==7||mc==8||mc==23||mc==24) && tmpscr->door[up]==lock)
18231
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 454 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 454 times.
✗ Branch 7 not taken.
454 || ((mc==151||mc==152||mc==167||mc==168) && tmpscr->door[down]==lock)
18232
3/6
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 454 times.
✗ Branch 5 not taken.
454 || ((mc==64||mc==65||mc==80||mc==81) && tmpscr->door[left]==lock)
18233
4/8
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 454 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 454 times.
454 || ((mc==78||mc==79||mc==94||mc==95) && tmpscr->door[right]==lock));
18234 454 return ret;
18235 }
18236
18237 3376323 void HeroClass::oldchecklockblock()
18238 {
18239
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 3362917 times.
3376323 if(toogam) return;
18240
18241 3362917 int32_t bx = x.getInt()&0xF0;
18242 3362917 int32_t bx2 = int32_t(x+8)&0xF0;
18243 3362917 int32_t by = y.getInt()&0xF0;
18244
18245
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 823846 times.
✓ Branch 2 taken 660221 times.
✓ Branch 3 taken 915663 times.
✓ Branch 4 taken 963187 times.
3362917 switch(dir)
18246 {
18247 case up:
18248
4/4
✓ Branch 0 taken 125482 times.
✓ Branch 1 taken 698364 times.
✓ Branch 2 taken 2339 times.
✓ Branch 3 taken 123143 times.
823846 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
18249
18250 823846 break;
18251
18252 case down:
18253 660221 by+=16;
18254 660221 break;
18255
18256 case left:
18257
2/2
✓ Branch 0 taken 408722 times.
✓ Branch 1 taken 506941 times.
915663 if((((int32_t)x)&0x0F)<8)
18258 506941 bx-=16;
18259
18260
2/2
✓ Branch 0 taken 551084 times.
✓ Branch 1 taken 364579 times.
915663 if(y.getInt()&8)
18261 {
18262 364579 by+=16;
18263 364579 }
18264
18265 915663 bx2=bx;
18266 915663 break;
18267
18268 case right:
18269 963187 bx+=16;
18270
18271
2/2
✓ Branch 0 taken 592352 times.
✓ Branch 1 taken 370835 times.
963187 if(y.getInt()&8)
18272 {
18273 370835 by+=16;
18274 370835 }
18275
18276 963187 bx2=bx;
18277 963187 break;
18278 }
18279
18280 3362917 bool found1=false;
18281 3362917 bool found2=false;
18282 3362917 int32_t foundlayer = -1;
18283 3362917 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
18284 3362917 newcombo const& cmb = combobuf[cid1];
18285 3362917 newcombo const& cmb2 = combobuf[cid2];
18286 // Layer 0 is overridden by Locked Doors
18287
5/8
✓ Branch 0 taken 380 times.
✓ Branch 1 taken 3362537 times.
✓ Branch 2 taken 380 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 380 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 380 times.
3362917 if((cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1) && !islockeddoor(bx,by,dLOCKED)))
18288 {
18289 380 found1=true;
18290 380 foundlayer = 0;
18291 380 }
18292
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3362537 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3362537 else if (cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, -1) && !islockeddoor(bx2,by,dLOCKED))
18293 {
18294 found2=true;
18295 foundlayer = 0;
18296 }
18297
18298
2/2
✓ Branch 0 taken 6725834 times.
✓ Branch 1 taken 3362917 times.
10088751 for (int32_t i = 0; i <= 1; ++i)
18299 {
18300
2/2
✓ Branch 0 taken 5628297 times.
✓ Branch 1 taken 1097537 times.
6725834 if(tmpscr2[i].valid!=0)
18301 {
18302
2/2
✓ Branch 0 taken 989682 times.
✓ Branch 1 taken 107855 times.
1097537 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18303 {
18304
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 989682 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
989682 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
18305
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 989682 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
989682 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
18306 989682 }
18307 else
18308 {
18309
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
18310
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
18311 }
18312 1097537 }
18313 6725834 }
18314
18315
18316 // Layers
18317
3/4
✓ Branch 0 taken 3362537 times.
✓ Branch 1 taken 380 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3362537 times.
3362917 if(!(found1 || found2))
18318 {
18319 3362537 foundlayer = -1;
18320
2/2
✓ Branch 0 taken 3362537 times.
✓ Branch 1 taken 6725074 times.
10087611 for(int32_t i=0; i<2; i++)
18321 {
18322 6725074 cid1 = MAPCOMBO2(i, bx, by);
18323 6725074 cid2 = MAPCOMBO2(i, bx2, by);
18324 6725074 newcombo const& cmb = combobuf[cid1];
18325 6725074 newcombo const& cmb2 = combobuf[cid2];
18326
2/2
✓ Branch 0 taken 3362537 times.
✓ Branch 1 taken 3362537 times.
6725074 if (i == 0)
18327 {
18328
2/2
✓ Branch 0 taken 3220425 times.
✓ Branch 1 taken 142112 times.
3362537 if(tmpscr2[1].valid!=0)
18329 {
18330
2/2
✓ Branch 0 taken 97558 times.
✓ Branch 1 taken 44554 times.
142112 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18331 {
18332
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97558 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97558 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue; //Continue, because It didn't find any on layer 0, and if you're checking
18333
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97558 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97558 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue; //layer 1 and there's a bridge on layer 2, stop checking layer 1.
18334 97558 }
18335 else
18336 {
18337
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44554 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
18338
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44554 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
18339 }
18340 142112 }
18341 3362537 }
18342
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6725074 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6725074 if(cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
18343 {
18344 found1=true;
18345 foundlayer = i+1;
18346 //zprint("Found layer: %d \n", i);
18347 break;
18348 }
18349
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6725074 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6725074 else if(cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, i))
18350 {
18351 found2=true;
18352 foundlayer = i+1;
18353 //zprint("Found layer: %d \n", i);
18354 break;
18355 }
18356 6725074 }
18357 3362537 }
18358
18359
4/4
✓ Branch 0 taken 3362537 times.
✓ Branch 1 taken 380 times.
✓ Branch 2 taken 3362885 times.
✓ Branch 3 taken 32 times.
3362917 if(!(found1 || found2) || pushing<8)
18360 {
18361 3362885 return;
18362 }
18363
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 newcombo const& cmb3 = combobuf[found1 ? cid1 : cid2];
18364
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 25 times.
32 if(!try_locked_combo(cmb3))
18365 25 return;
18366
18367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(cmb.usrflags&cflag16)
18368 {
18369 setxmapflag(1<<cmb.attribytes[5]);
18370 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
18371 }
18372 else
18373 {
18374 7 setmapflag(mLOCKBLOCK);
18375 7 remove_lockblocks((currscr>=128)?1:0);
18376 }
18377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if ( cmb3.usrflags&cflag3 )
18378 {
18379 if ( (cmb3.attribytes[3]) )
18380 sfx(cmb3.attribytes[3]);
18381 }
18382 7 else sfx(WAV_DOOR);
18383 3376323 }
18384
18385 3376323 void HeroClass::oldcheckbosslockblock()
18386 {
18387
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 3362917 times.
3376323 if(toogam) return;
18388
18389 3362917 int32_t bx = x.getInt()&0xF0;
18390 3362917 int32_t bx2 = int32_t(x+8)&0xF0;
18391 3362917 int32_t by = y.getInt()&0xF0;
18392
18393
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 823846 times.
✓ Branch 2 taken 660221 times.
✓ Branch 3 taken 915663 times.
✓ Branch 4 taken 963187 times.
3362917 switch(dir)
18394 {
18395 case up:
18396
4/4
✓ Branch 0 taken 125482 times.
✓ Branch 1 taken 698364 times.
✓ Branch 2 taken 2339 times.
✓ Branch 3 taken 123143 times.
823846 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
18397
18398 823846 break;
18399
18400 case down:
18401 660221 by+=16;
18402 660221 break;
18403
18404 case left:
18405
2/2
✓ Branch 0 taken 408722 times.
✓ Branch 1 taken 506941 times.
915663 if((((int32_t)x)&0x0F)<8)
18406 506941 bx-=16;
18407
18408
2/2
✓ Branch 0 taken 551084 times.
✓ Branch 1 taken 364579 times.
915663 if(y.getInt()&8)
18409 {
18410 364579 by+=16;
18411 364579 }
18412
18413 915663 bx2=bx;
18414 915663 break;
18415
18416 case right:
18417 963187 bx+=16;
18418
18419
2/2
✓ Branch 0 taken 592352 times.
✓ Branch 1 taken 370835 times.
963187 if(y.getInt()&8)
18420 {
18421 370835 by+=16;
18422 370835 }
18423
18424 963187 bx2=bx;
18425 963187 break;
18426 }
18427
18428
18429 3362917 bool found1 = false;
18430 3362917 bool found2 = false;
18431 3362917 int32_t foundlayer = -1;
18432 3362917 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
18433 3362917 newcombo const& cmb = combobuf[cid1];
18434 3362917 newcombo const& cmb2 = combobuf[cid2];
18435 // Layer 0 is overridden by Locked Doors
18436
5/8
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 3362843 times.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 74 times.
3362917 if ((cmb.type == cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx, by, 1, -1) && !islockeddoor(bx, by, dLOCKED)))
18437 {
18438 74 found1 = true;
18439 74 foundlayer = 0;
18440 74 }
18441
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3362843 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3362843 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2, by, 1, -1) && !islockeddoor(bx2, by, dLOCKED))
18442 {
18443 found2 = true;
18444 foundlayer = 0;
18445 }
18446
18447
2/2
✓ Branch 0 taken 6725834 times.
✓ Branch 1 taken 3362917 times.
10088751 for (int32_t i = 0; i <= 1; ++i)
18448 {
18449
2/2
✓ Branch 0 taken 5628297 times.
✓ Branch 1 taken 1097537 times.
6725834 if (tmpscr2[i].valid != 0)
18450 {
18451
2/2
✓ Branch 0 taken 989682 times.
✓ Branch 1 taken 107855 times.
1097537 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18452 {
18453
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 989682 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
989682 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
18454
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 989682 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
989682 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
18455 989682 }
18456 else
18457 {
18458
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
18459
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
18460 }
18461 1097537 }
18462 6725834 }
18463
18464
18465 // Layers
18466
3/4
✓ Branch 0 taken 3362843 times.
✓ Branch 1 taken 74 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3362843 times.
3362917 if (!(found1 || found2))
18467 {
18468 3362843 foundlayer = -1;
18469
2/2
✓ Branch 0 taken 3362843 times.
✓ Branch 1 taken 6725686 times.
10088529 for (int32_t i = 0; i < 2; i++)
18470 {
18471 6725686 cid1 = MAPCOMBO2(i, bx, by);
18472 6725686 cid2 = MAPCOMBO2(i, bx2, by);
18473 6725686 newcombo const& cmb = combobuf[cid1];
18474 6725686 newcombo const& cmb2 = combobuf[cid2];
18475
2/2
✓ Branch 0 taken 3362843 times.
✓ Branch 1 taken 3362843 times.
6725686 if (i == 0)
18476 {
18477
2/2
✓ Branch 0 taken 3220639 times.
✓ Branch 1 taken 142204 times.
3362843 if (tmpscr2[1].valid != 0)
18478 {
18479
2/2
✓ Branch 0 taken 97586 times.
✓ Branch 1 taken 44618 times.
142204 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18480 {
18481
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97586 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97586 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
18482
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97586 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97586 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
18483 97586 }
18484 else
18485 {
18486
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44618 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44618 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
18487
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44618 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44618 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
18488 }
18489 142204 }
18490 3362843 }
18491
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6725686 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6725686 if (cmb.type == cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx, by, 1, i))
18492 {
18493 found1 = true;
18494 foundlayer = i;
18495 break;
18496 }
18497
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6725686 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6725686 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2, by, 1, i))
18498 {
18499 found2 = true;
18500 foundlayer = i;
18501 break;
18502 }
18503 6725686 }
18504 3362843 }
18505
18506
4/4
✓ Branch 0 taken 3362843 times.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 3362897 times.
✓ Branch 3 taken 20 times.
3362917 if (!(found1 || found2) || pushing < 8)
18507 {
18508 3362897 return;
18509 }
18510
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 int32_t cid = found1 ? cid1 : cid2;
18511
18512
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 17 times.
20 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
18513
18514
18515 // Run Boss Key Script
18516 3 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
18517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 for ( int32_t q = 0; q < MAXITEMS; ++q )
18518 {
18519
2/2
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 3 times.
204 if ( itemsbuf[q].family == itype_bosskey )
18520 {
18521 3 key_item = q; break;
18522 }
18523 201 }
18524
2/8
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18525 {
18526 ri = &(itemScriptData[key_item]);
18527 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18528 ri->Clear();
18529 item_doscript[key_item] = 1;
18530 itemscriptInitialised[key_item] = 0;
18531 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18532 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18533 }
18534
18535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(cmb.usrflags&cflag16)
18536 {
18537 setxmapflag(1<<cmb.attribytes[5]);
18538 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
18539 }
18540 else
18541 {
18542 3 setmapflag(mBOSSLOCKBLOCK);
18543 3 remove_bosslockblocks((currscr>=128)?1:0);
18544 }
18545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( (combobuf[cid].attribytes[3]) )
18546 3 sfx(combobuf[cid].attribytes[3]);
18547 3376323 }
18548
18549 9739968 void HeroClass::oldcheckchest(int32_t type)
18550 {
18551 // chests aren't affected by tmpscr->flags2&fAIRCOMBOS
18552
5/6
✓ Branch 0 taken 9699750 times.
✓ Branch 1 taken 40218 times.
✓ Branch 2 taken 9690693 times.
✓ Branch 3 taken 9057 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9690693 times.
9739968 if(toogam || z>0 || fakez > 0) return;
18553
2/2
✓ Branch 0 taken 9452553 times.
✓ Branch 1 taken 238140 times.
9690693 if(pushing<8) return;
18554 238140 int32_t bx = x.getInt()&0xF0;
18555 238140 int32_t bx2 = int32_t(x+8)&0xF0;
18556 238140 int32_t by = y.getInt()&0xF0;
18557
18558
3/4
✓ Branch 0 taken 122622 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57915 times.
✓ Branch 3 taken 57603 times.
238140 switch(dir)
18559 {
18560 case up:
18561
2/2
✓ Branch 0 taken 561 times.
✓ Branch 1 taken 57042 times.
57603 if(isSideViewHero()) return;
18562
18563
3/4
✓ Branch 0 taken 10323 times.
✓ Branch 1 taken 46719 times.
✓ Branch 2 taken 10323 times.
✗ Branch 3 not taken.
57042 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
18564
18565 57042 break;
18566
18567 case left:
18568 case right:
18569
2/2
✓ Branch 0 taken 2793 times.
✓ Branch 1 taken 119829 times.
122622 if(isSideViewHero()) break;
18570 [[fallthrough]];
18571 case down:
18572 177744 return;
18573 }
18574
18575 59835 bool found=false;
18576 59835 bool itemflag=false;
18577
18578
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 59827 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
59835 if((combobuf[MAPCOMBO(bx,by)].type==type && _effectflag(bx,by,1, -1))||
18579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59827 times.
59827 (combobuf[MAPCOMBO(bx2,by)].type==type && _effectflag(bx2,by,1, -1)))
18580 {
18581 8 found=true;
18582 8 }
18583
2/2
✓ Branch 0 taken 119670 times.
✓ Branch 1 taken 59835 times.
179505 for (int32_t i = 0; i <= 1; ++i)
18584 {
18585
2/2
✓ Branch 0 taken 98904 times.
✓ Branch 1 taken 20766 times.
119670 if(tmpscr2[i].valid!=0)
18586 {
18587
2/2
✓ Branch 0 taken 19905 times.
✓ Branch 1 taken 861 times.
20766 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18588 {
18589
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 19905 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
19905 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
18590
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 19905 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
19905 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
18591 19905 }
18592 else
18593 {
18594
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
861 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
18595
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
861 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
18596 }
18597 20766 }
18598 119670 }
18599
18600
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 59827 times.
59835 if(!found)
18601 {
18602
2/2
✓ Branch 0 taken 59827 times.
✓ Branch 1 taken 119654 times.
179481 for(int32_t i=0; i<2; i++)
18603 {
18604
2/2
✓ Branch 0 taken 59827 times.
✓ Branch 1 taken 59827 times.
119654 if (i == 0)
18605 {
18606
2/2
✓ Branch 0 taken 58540 times.
✓ Branch 1 taken 1287 times.
59827 if(tmpscr2[1].valid!=0)
18607 {
18608
2/2
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 381 times.
1287 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18609 {
18610
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
906 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
18611
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
906 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
18612 906 }
18613 else
18614 {
18615
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
381 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
18616
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
381 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
18617 }
18618 1287 }
18619 59827 }
18620
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 119654 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
119654 if((combobuf[MAPCOMBO2(i,bx,by)].type==type && _effectflag(bx,by,1, i))||
18621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119654 times.
119654 (combobuf[MAPCOMBO2(i,bx2,by)].type==type && _effectflag(bx2,by,1, i)))
18622 {
18623 found=true;
18624 break;
18625 }
18626 119654 }
18627 59827 }
18628
18629
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 59827 times.
59835 if(!found)
18630 {
18631 59827 return;
18632 }
18633
18634
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 switch(type)
18635 {
18636 case cLOCKEDCHEST:
18637 if(!usekey()) return;
18638
18639 setmapflag(mLOCKEDCHEST);
18640 break;
18641
18642 case cCHEST:
18643 8 setmapflag(mCHEST);
18644 8 break;
18645
18646 case cBOSSCHEST:
18647 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
18648 // Run Boss Key Script
18649 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
18650 for ( int32_t q = 0; q < MAXITEMS; ++q )
18651 {
18652 if ( itemsbuf[q].family == itype_bosskey )
18653 {
18654 key_item = q; break;
18655 }
18656 }
18657 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18658 {
18659 ri = &(itemScriptData[key_item]);
18660 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18661 ri->Clear();
18662 item_doscript[key_item] = 1;
18663 itemscriptInitialised[key_item] = 0;
18664 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18665 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18666 }
18667 setmapflag(mBOSSCHEST);
18668 break;
18669 }
18670
18671 8 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
18672 8 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
18673 8 itemflag |= MAPFLAG(bx,by)==mfARMOS_ITEM;
18674 8 itemflag |= MAPFLAG(bx2,by)==mfARMOS_ITEM;
18675 8 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
18676 8 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
18677
18678
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!itemflag)
18679 {
18680 for(int32_t i=0; i<2; i++)
18681 {
18682 itemflag |= MAPFLAG2(i,bx,by)==mfARMOS_ITEM;
18683 itemflag |= MAPFLAG2(i,bx2,by)==mfARMOS_ITEM;
18684 itemflag |= MAPCOMBOFLAG2(i,bx,by)==mfARMOS_ITEM;
18685 itemflag |= MAPCOMBOFLAG2(i,bx2,by)==mfARMOS_ITEM;
18686 }
18687 }
18688
18689
3/6
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
8 if(itemflag && !getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM))
18690 {
18691
4/8
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
8 items.add(new item(x, y,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
18692 8 }
18693 9739968 }
18694
18695 463765 void HeroClass::checkchest(int32_t type)
18696 {
18697
4/4
✓ Branch 0 taken 319148 times.
✓ Branch 1 taken 144617 times.
✓ Branch 2 taken 144617 times.
✓ Branch 3 taken 174531 times.
463765 bool ischest = type == cCHEST || type == cLOCKEDCHEST || type == cBOSSCHEST;
18698
2/2
✓ Branch 0 taken 14957 times.
✓ Branch 1 taken 448808 times.
463765 bool islockblock = type == cLOCKBLOCK || type == cBOSSLOCKBLOCK;
18699
2/2
✓ Branch 0 taken 14957 times.
✓ Branch 1 taken 448808 times.
463765 bool islocked = type == cLOCKBLOCK || type == cLOCKEDCHEST;
18700
2/2
✓ Branch 0 taken 14957 times.
✓ Branch 1 taken 448808 times.
463765 bool isbosslocked = type == cBOSSLOCKBLOCK || type == cBOSSCHEST;
18701
2/2
✓ Branch 0 taken 29914 times.
✓ Branch 1 taken 433851 times.
463765 if(ischest)
18702 {
18703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433851 times.
433851 if(get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
18704 {
18705 oldcheckchest(type);
18706 return;
18707 }
18708 433851 }
18709
3/4
✓ Branch 0 taken 29914 times.
✓ Branch 1 taken 433851 times.
✓ Branch 2 taken 29914 times.
✗ Branch 3 not taken.
463765 if(islockblock && get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
18710 {
18711 if(type == cLOCKBLOCK)
18712 oldchecklockblock();
18713 else if(type == cBOSSLOCKBLOCK)
18714 oldcheckbosslockblock();
18715 return;
18716 }
18717
4/6
✓ Branch 0 taken 463765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 463009 times.
✓ Branch 3 taken 756 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 463009 times.
463765 if(toogam || z>0 || fakez > 0) return;
18718 463009 zfix bx, by;
18719 463009 zfix bx2, by2;
18720 463009 zfix fx(-1), fy(-1);
18721
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 98833 times.
✓ Branch 2 taken 104169 times.
✓ Branch 3 taken 123819 times.
✓ Branch 4 taken 136188 times.
463009 switch(dir)
18722 {
18723 case up:
18724 98833 by = y + (bigHitbox ? -2 : 6);
18725 98833 by2 = by;
18726 98833 bx = x + 4;
18727 98833 bx2 = bx + 8;
18728 98833 break;
18729 case down:
18730 104169 by = y + 17;
18731 104169 by2 = by;
18732 104169 bx = x + 4;
18733 104169 bx2 = bx + 8;
18734 104169 break;
18735 case left:
18736 123819 by = y + (bigHitbox ? 0 : 8);
18737 123819 by2 = y + 8;
18738 123819 bx = x - 2;
18739 123819 bx2 = x - 2;
18740 123819 break;
18741 case right:
18742 136188 by = y + (bigHitbox ? 0 : 8);
18743 136188 by2 = y + 8;
18744 136188 bx = x + 17;
18745 136188 bx2 = x + 17;
18746 136188 break;
18747 }
18748
18749 463009 int32_t found = -1;
18750 463009 int32_t foundlayer = 0;
18751
18752 463009 newcombo const* cmb = &combobuf[MAPCOMBO(bx,by)];
18753
18754
4/6
✓ Branch 0 taken 871 times.
✓ Branch 1 taken 462138 times.
✓ Branch 2 taken 871 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 871 times.
463009 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1))
18755 {
18756 871 found = MAPCOMBO(bx,by);
18757 871 fx = bx; fy = by;
18758
2/2
✓ Branch 0 taken 1742 times.
✓ Branch 1 taken 871 times.
2613 for (int32_t i = 0; i <= 1; ++i)
18759 {
18760
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 1357 times.
1742 if(tmpscr2[i].valid!=0)
18761 {
18762
1/2
✓ Branch 0 taken 1357 times.
✗ Branch 1 not taken.
1357 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18763 {
18764
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1357 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1357 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
18765 1357 }
18766 else
18767 {
18768 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
18769 }
18770 1357 }
18771 1742 }
18772 871 }
18773
2/2
✓ Branch 0 taken 871 times.
✓ Branch 1 taken 462138 times.
463009 if(found<0)
18774 {
18775 462138 cmb = &combobuf[MAPCOMBO(bx2,by2)];
18776
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 462115 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
462138 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, -1))
18777 {
18778 23 found = MAPCOMBO(bx2,by2);
18779
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 161 times.
184 for (int32_t i = 0; i <= 6; ++i)
18780 {
18781
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 46 times.
161 if(tmpscr2[i].valid!=0)
18782 {
18783
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18784 {
18785
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
46 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i])))
18786 {
18787 found = -1;
18788 break;
18789 }
18790 46 }
18791 else
18792 {
18793 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i])))
18794 {
18795 found = -1;
18796 break;
18797 }
18798 }
18799 46 }
18800 161 }
18801
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(found != -1)
18802 {
18803 23 fx = bx2; fy = by2;
18804 23 }
18805 23 }
18806 462138 }
18807
18808
2/2
✓ Branch 0 taken 894 times.
✓ Branch 1 taken 462115 times.
463009 if(found<0)
18809 {
18810
2/2
✓ Branch 0 taken 462062 times.
✓ Branch 1 taken 2772425 times.
3234487 for(int32_t i=0; i<6; i++)
18811 {
18812 2772425 cmb = &combobuf[MAPCOMBO2(i,bx,by)];
18813
4/6
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 2772372 times.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 53 times.
2772425 if(combobuf[MAPCOMBO2(i,bx,by)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
18814 {
18815 53 found = MAPCOMBO2(i,bx,by);
18816
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 265 times.
318 for(int32_t j = i+1; j < 6; ++j)
18817 {
18818
2/2
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 53 times.
265 if (tmpscr2[j].valid!=0)
18819 {
18820
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18821 {
18822
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[j])))
18823 {
18824 found = -1;
18825 break;
18826 }
18827 53 }
18828 else
18829 {
18830 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[j])))
18831 {
18832 found = -1;
18833 break;
18834 }
18835 }
18836 53 }
18837 265 }
18838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(found>-1)
18839 {
18840 53 foundlayer = i+1;
18841 53 fx = bx; fy = by;
18842 53 break;
18843 }
18844 }
18845 2772372 cmb = &combobuf[MAPCOMBO2(i,bx2,by2)];
18846
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2772372 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2772372 if(combobuf[MAPCOMBO2(i,bx2,by2)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, i))
18847 {
18848 found = MAPCOMBO2(i,bx2,by2);
18849 for(int32_t j = i+1; j < 6; ++j)
18850 {
18851 if (tmpscr2[j].valid!=0)
18852 {
18853 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18854 {
18855 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[j])))
18856 {
18857 found = -1;
18858 break;
18859 }
18860 }
18861 else
18862 {
18863 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[j])))
18864 {
18865 found = -1;
18866 break;
18867 }
18868 }
18869 }
18870 }
18871 if(found>-1)
18872 {
18873 foundlayer = i+1;
18874 fx = bx2; fy = by2;
18875 break;
18876 }
18877 }
18878 2772372 }
18879 462115 }
18880
18881
2/2
✓ Branch 0 taken 947 times.
✓ Branch 1 taken 462062 times.
463009 if(found<0) return;
18882 947 cmb = &combobuf[found];
18883
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
947 switch(dir)
18884 {
18885 case up:
18886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
947 if(cmb->usrflags&cflag10)
18887 return;
18888 947 break;
18889 case down:
18890 if(cmb->usrflags&cflag9)
18891 return;
18892 break;
18893 case left:
18894 if(cmb->usrflags&cflag12)
18895 return;
18896 break;
18897 case right:
18898 if(cmb->usrflags&cflag11)
18899 return;
18900 break;
18901 }
18902 947 int32_t intbtn = cmb->attribytes[2];
18903
18904
1/2
✓ Branch 0 taken 947 times.
✗ Branch 1 not taken.
947 if(intbtn) //
18905 {
18906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
947 if(cmb->usrflags & cflag13) //display prompt
18907 {
18908 947 int altcmb = cmb->attributes[2]/10000;
18909 947 prompt_combo = cmb->attributes[1]/10000;
18910
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
947 if(altcmb && ((islocked && !can_locked_combo(*cmb))
18911 || (isbosslocked && !(game->lvlitems[dlevel]&liBOSSKEY))))
18912 prompt_combo = altcmb;
18913 947 prompt_cset = cmb->attribytes[4];
18914 947 prompt_x = cmb->attrishorts[0];
18915 947 prompt_y = cmb->attrishorts[1];
18916 947 }
18917
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 935 times.
947 if(!getIntBtnInput(intbtn, true, true, false, false))
18918 {
18919 935 return; //Button not pressed
18920 }
18921 12 }
18922 else if(pushing < 8) return; //Not pushing against chest enough
18923
18924
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(ischest)
18925 {
18926
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!trigger_chest(foundlayer, COMBOPOS(fx,fy))) return;
18927 12 }
18928 else if(islockblock)
18929 {
18930 if(!trigger_lockblock(foundlayer, COMBOPOS(fx,fy))) return;
18931 }
18932
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(intbtn && (cmb->usrflags & cflag13))
18933 12 prompt_combo = 0;
18934 463765 }
18935
18936 3395231 void HeroClass::checkgenpush()
18937 {
18938
4/4
✓ Branch 0 taken 84801 times.
✓ Branch 1 taken 3310430 times.
✓ Branch 2 taken 71183 times.
✓ Branch 3 taken 13618 times.
3395231 if(pushing < 8 || pushing % 8) return;
18939 13618 zfix bx, by;
18940 13618 zfix bx2, by2;
18941
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3350 times.
✓ Branch 2 taken 3380 times.
✓ Branch 3 taken 3170 times.
✓ Branch 4 taken 3718 times.
13618 switch(dir)
18942 {
18943 case up:
18944 3350 by = y + (bigHitbox ? -2 : 6);
18945 3350 by2 = by;
18946 3350 bx = x + 4;
18947 3350 bx2 = bx + 8;
18948 3350 break;
18949 case down:
18950 3380 by = y + 17;
18951 3380 by2 = by;
18952 3380 bx = x + 4;
18953 3380 bx2 = bx + 8;
18954 3380 break;
18955 case left:
18956 3170 by = y + (bigHitbox ? 0 : 8);
18957 3170 by2 = y + 8;
18958 3170 bx = x - 2;
18959 3170 bx2 = x - 2;
18960 3170 break;
18961 case right:
18962 3718 by = y + (bigHitbox ? 0 : 8);
18963 3718 by2 = y + 8;
18964 3718 bx = x + 17;
18965 3718 bx2 = x + 17;
18966 3718 break;
18967 }
18968 13618 auto pos1 = COMBOPOS(bx,by);
18969 13618 auto pos2 = COMBOPOS(bx2,by2);
18970
2/2
✓ Branch 0 taken 13618 times.
✓ Branch 1 taken 95326 times.
108944 for(auto layer = 0; layer < 7; ++layer)
18971 {
18972 95326 mapscr* tmp = FFCore.tempScreens[layer];
18973
18974 95326 newcombo const& cmb1 = combobuf[tmp->data[pos1]];
18975
1/2
✓ Branch 0 taken 95326 times.
✗ Branch 1 not taken.
95326 if(cmb1.triggerflags[1] & combotriggerPUSH)
18976 do_trigger_combo(layer,pos1);
18977
18978
2/2
✓ Branch 0 taken 75915 times.
✓ Branch 1 taken 19411 times.
95326 if(pos1==pos2) continue;
18979
18980 19411 newcombo const& cmb2 = combobuf[tmp->data[pos2]];
18981
1/2
✓ Branch 0 taken 19411 times.
✗ Branch 1 not taken.
19411 if(cmb2.triggerflags[1] & combotriggerPUSH)
18982 do_trigger_combo(layer,pos2);
18983 19411 }
18984
2/2
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 12757 times.
13618 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
18985 {
18986 861 word c = tmpscr->numFFC();
18987
2/2
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 5878 times.
6739 for(word i=0; i<c; i++)
18988 {
18989
4/4
✓ Branch 0 taken 5719 times.
✓ Branch 1 taken 159 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 5703 times.
5878 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
18990 {
18991 175 ffcdata& ffc = tmpscr->ffcs[i];
18992 175 newcombo const& cmb3 = combobuf[ffc.getData()];
18993
1/2
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
175 if(cmb3.triggerflags[1] & combotriggerPUSH)
18994 {
18995 do_trigger_combo_ffc(i);
18996 break;
18997 }
18998 175 }
18999 5878 }
19000 861 }
19001 3395231 }
19002
19003 3395232 void HeroClass::checksigns() //Also checks for generic trigger buttons
19004 {
19005
5/6
✓ Branch 0 taken 3381826 times.
✓ Branch 1 taken 13406 times.
✓ Branch 2 taken 3378549 times.
✓ Branch 3 taken 3277 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3378549 times.
3395232 if(toogam || z>0 || fakez>0) return;
19006
5/6
✓ Branch 0 taken 3353646 times.
✓ Branch 1 taken 24903 times.
✓ Branch 2 taken 44317 times.
✓ Branch 3 taken 3309329 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 44317 times.
3378549 if(msg_active || (msg_onscreen && get_bit(quest_rules, qr_MSGDISAPPEAR)))
19007 24903 return; //Don't overwrite a message waiting to be dismissed
19008 3353646 zfix bx, by;
19009 3353646 zfix bx2, by2;
19010 3353646 zfix fx(-1), fy(-1);
19011
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 804777 times.
✓ Branch 2 taken 662660 times.
✓ Branch 3 taken 916667 times.
✓ Branch 4 taken 969542 times.
3353646 switch(dir)
19012 {
19013 case up:
19014 804777 by = y + (bigHitbox ? -2 : 6);
19015 804777 by2 = by;
19016 804777 bx = x + 4;
19017 804777 bx2 = bx + 8;
19018 804777 break;
19019 case down:
19020 662660 by = y + 17;
19021 662660 by2 = by;
19022 662660 bx = x + 4;
19023 662660 bx2 = bx + 8;
19024 662660 break;
19025 case left:
19026 916667 by = y + (bigHitbox ? 0 : 8);
19027 916667 by2 = y + 8;
19028 916667 bx = x - 2;
19029 916667 bx2 = x - 2;
19030 916667 break;
19031 case right:
19032 969542 by = y + (bigHitbox ? 0 : 8);
19033 969542 by2 = y + 8;
19034 969542 bx = x + 17;
19035 969542 bx2 = x + 17;
19036 969542 break;
19037 }
19038
19039 3353646 int32_t found = -1;
19040 3353646 int32_t foundffc = -1;
19041 3353646 int32_t found_lyr = 0;
19042 3353646 bool found_sign = false;
19043 3353646 int32_t tmp_cid = MAPCOMBO(bx,by);
19044 3353646 newcombo const* tmp_cmb = &combobuf[tmp_cid];
19045
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3353646 times.
✓ Branch 2 taken 3353646 times.
✗ Branch 3 not taken.
6707292 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19046 3353646 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, -1))
19047 {
19048 found = tmp_cid;
19049 fx = bx; fy = by;
19050 for (int32_t i = 0; i <= 1; ++i)
19051 {
19052 if(tmpscr2[i].valid!=0)
19053 {
19054 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19055 {
19056 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
19057 }
19058 else
19059 {
19060 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
19061 }
19062 }
19063 }
19064 }
19065 3353646 tmp_cid = MAPCOMBO(bx2,by2);
19066 3353646 tmp_cmb = &combobuf[tmp_cid];
19067
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3353646 times.
✓ Branch 2 taken 3353646 times.
✗ Branch 3 not taken.
6707292 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19068 3353646 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, -1))
19069 {
19070 found = tmp_cid;
19071 fx = bx2; fy = by2;
19072 for (int32_t i = 0; i <= 1; ++i)
19073 {
19074 if(tmpscr2[i].valid!=0)
19075 {
19076 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19077 {
19078 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
19079 }
19080 else
19081 {
19082 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
19083 }
19084 }
19085 }
19086 }
19087
19088
2/2
✓ Branch 0 taken 3209507 times.
✓ Branch 1 taken 144139 times.
3353646 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
19089 {
19090 144139 word c = tmpscr->numFFC();
19091
2/2
✓ Branch 0 taken 144139 times.
✓ Branch 1 taken 803178 times.
947317 for(word i=0; i<c; i++)
19092 {
19093
4/4
✓ Branch 0 taken 795563 times.
✓ Branch 1 taken 7615 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 794870 times.
803178 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
19094 {
19095 8308 ffcdata& ffc = tmpscr->ffcs[i];
19096 8308 tmp_cmb = &combobuf[ffc.getData()];
19097
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8308 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8308 times.
8308 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19098 8308 || tmp_cmb->triggerbtn) && true) //!TODO: FFC effect flag?
19099 {
19100 foundffc = i;
19101 break;
19102 }
19103 8308 }
19104 803178 }
19105 144139 }
19106
19107
2/4
✓ Branch 0 taken 3353646 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3353646 times.
3353646 if(found<0 && foundffc < 0)
19108 {
19109
2/2
✓ Branch 0 taken 3353074 times.
✓ Branch 1 taken 20119016 times.
23472090 for(int32_t i=0; i<6; i++)
19110 {
19111 20119016 tmp_cid = MAPCOMBO2(i,bx,by);
19112 20119016 tmp_cmb = &combobuf[tmp_cid];
19113
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20119016 times.
✓ Branch 2 taken 20118444 times.
✓ Branch 3 taken 572 times.
40238032 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19114 20119016 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, i))
19115 {
19116 572 found = tmp_cid;
19117 572 found_lyr = i+1;
19118 572 fx = bx; fy = by;
19119
3/4
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✓ Branch 3 taken 440 times.
572 if (i == 0 && tmpscr2[1].valid!=0)
19120 {
19121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 440 times.
440 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19122 {
19123
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
440 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
19124 440 }
19125 else
19126 {
19127 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
19128 }
19129 440 }
19130 572 }
19131 20119016 tmp_cid = MAPCOMBO2(i,bx2,by2);
19132 20119016 tmp_cmb = &combobuf[tmp_cid];
19133
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20119016 times.
✓ Branch 2 taken 20118500 times.
✓ Branch 3 taken 516 times.
40238032 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19134 20119016 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, i))
19135 {
19136 516 found = tmp_cid;
19137 516 found_lyr = i+1;
19138 516 fx = bx2; fy = by2;
19139
3/4
✓ Branch 0 taken 516 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 390 times.
516 if (i == 0 && tmpscr2[1].valid!=0)
19140 {
19141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 390 times.
390 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19142 {
19143
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
390 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
19144 390 }
19145 else
19146 {
19147 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
19148 }
19149 390 }
19150 516 }
19151
2/2
✓ Branch 0 taken 20118444 times.
✓ Branch 1 taken 572 times.
20119016 if(found>-1) break;
19152 20118444 }
19153 3353646 }
19154
19155
3/4
✓ Branch 0 taken 3353074 times.
✓ Branch 1 taken 572 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3353074 times.
3353646 if(found<0&&foundffc<0) return;
19156
1/2
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
572 newcombo const& cmb = (foundffc<0?combobuf[found]:combobuf[tmpscr->ffcs[foundffc].getData()]);
19157
19158 572 byte signInput = 0;
19159 572 bool didsign = false;
19160
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 572 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
572 if(cmb.type == cSIGNPOST && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
19161 {
19162 switch(dir)
19163 {
19164 case up:
19165 if(cmb.usrflags&cflag10)
19166 goto endsigns;
19167 break;
19168 case down:
19169 if(cmb.usrflags&cflag9)
19170 goto endsigns;
19171 break;
19172 case left:
19173 if(cmb.usrflags&cflag12)
19174 goto endsigns;
19175 break;
19176 case right:
19177 if(cmb.usrflags&cflag11)
19178 goto endsigns;
19179 break;
19180 }
19181 int32_t intbtn = cmb.attribytes[2];
19182
19183 if(intbtn) //
19184 {
19185 signInput = getIntBtnInput(intbtn, true, true, false, false);
19186 if(!signInput)
19187 {
19188 if(cmb.usrflags & cflag13) //display prompt
19189 {
19190 prompt_combo = cmb.attributes[1]/10000;
19191 prompt_cset = cmb.attribytes[4];
19192 prompt_x = cmb.attrishorts[0];
19193 prompt_y = cmb.attrishorts[1];
19194 }
19195 goto endsigns; //Button not pressed
19196 }
19197 }
19198 else if(pushing < 8 || pushing%8) goto endsigns; //Not pushing against sign enough
19199
19200 trigger_sign(cmb);
19201 didsign = true;
19202 }
19203 endsigns:
19204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 572 times.
572 if(!cmb.triggerbtn) return;
19205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 572 times.
572 if(on_cooldown(found_lyr, COMBOPOS(fx,fy))) return;
19206
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 91 times.
✓ Branch 2 taken 400 times.
✓ Branch 3 taken 46 times.
✓ Branch 4 taken 35 times.
572 switch(dir)
19207 {
19208 case down:
19209
1/2
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
91 if(!(cmb.triggerflags[0] & combotriggerBTN_TOP))
19210 return;
19211 91 break;
19212 case up:
19213
1/2
✓ Branch 0 taken 400 times.
✗ Branch 1 not taken.
400 if(!(cmb.triggerflags[0] & combotriggerBTN_BOTTOM))
19214 return;
19215 400 break;
19216 case right:
19217
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if(!(cmb.triggerflags[0] & combotriggerBTN_LEFT))
19218 return;
19219 46 break;
19220 case left:
19221
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!(cmb.triggerflags[0] & combotriggerBTN_RIGHT))
19222 return;
19223 35 break;
19224 }
19225
3/4
✓ Branch 0 taken 561 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 561 times.
572 if(getIntBtnInput(cmb.triggerbtn, true, true, false, false) || checkIntBtnVal(cmb.triggerbtn, signInput))
19226 {
19227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (foundffc >= 0)
19228 do_trigger_combo_ffc(foundffc, didsign ? ctrigIGNORE_SIGN : 0);
19229 else
19230 11 do_trigger_combo(found_lyr, COMBOPOS(fx,fy), didsign ? ctrigIGNORE_SIGN : 0);
19231 11 }
19232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 561 times.
561 else if(cmb.type == cBUTTONPROMPT)
19233 {
19234 prompt_combo = cmb.attributes[0]/10000;
19235 prompt_cset = cmb.attribytes[0];
19236 prompt_x = cmb.attrishorts[0];
19237 prompt_y = cmb.attrishorts[1];
19238 }
19239
1/2
✓ Branch 0 taken 561 times.
✗ Branch 1 not taken.
561 else if(cmb.prompt_cid)
19240 {
19241 561 prompt_combo = cmb.prompt_cid;
19242 561 prompt_cset = cmb.prompt_cs;
19243 561 prompt_x = cmb.prompt_x;
19244 561 prompt_y = cmb.prompt_y;
19245 561 }
19246 3395232 }
19247
19248 3391281 void HeroClass::checklocked()
19249 {
19250
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 3377875 times.
3391281 if(toogam) return; //Walk through walls.
19251
19252
2/2
✓ Branch 0 taken 2294633 times.
✓ Branch 1 taken 1083242 times.
3377875 if(!isdungeon()) return;
19253
19254
3/4
✓ Branch 0 taken 2294633 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4314 times.
✓ Branch 3 taken 2290319 times.
2294633 if( !diagonalMovement && pushing!=8) return;
19255 /*This is required to allow the player to open a door, while sliding along a wall (pressing in the direction of the door, and sliding left or right)
19256 */
19257
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4314 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4314 if ( diagonalMovement && pushing < 8 ) return; //Allow wall walking Should I add a quest rule for this? -Z
19258
19259
19260 4314 bool found = false;
19261
2/2
✓ Branch 0 taken 17256 times.
✓ Branch 1 taken 4314 times.
21570 for ( int32_t q = 0; q < 4; q++ ) {
19262
4/4
✓ Branch 0 taken 16740 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 246 times.
✓ Branch 3 taken 16494 times.
17256 if ( tmpscr->door[q] == dLOCKED || tmpscr->door[q] == dBOSS ) { found = true; }
19263 17256 }
19264
19265
2/2
✓ Branch 0 taken 731 times.
✓ Branch 1 taken 3583 times.
4314 if ( !found ) return;
19266
19267 731 int32_t si = (currmap<<7) + currscr;
19268 731 int32_t di = 0;
19269
19270
19271
19272
2/4
✓ Branch 0 taken 731 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 731 times.
731 if ( diagonalMovement || get_bit(quest_rules, qr_DISABLE_4WAY_GRIDLOCK))
19273 {
19274 //Up door
19275 if ( y <= 32 && x >= 112 && x <= 128 )
19276 {
19277 if (
19278 dir == up || dir == l_up || dir == r_up //|| Up() || ( Up()&&Left()) || ( Up()&&Right())
19279
19280 )
19281 {
19282 di = nextscr(up);
19283 if(tmpscr->door[0]==dLOCKED)
19284 {
19285 if(usekey())
19286 {
19287 putdoor(scrollbuf,0,up,dUNLOCKED);
19288 tmpscr->door[0]=dUNLOCKED;
19289 setmapflag(si, mDOOR_UP);
19290
19291 if(di != 0xFFFF)
19292 setmapflag(di, mDOOR_DOWN);
19293 sfx(WAV_DOOR);
19294 markBmap(-1);
19295 }
19296 else return;
19297 }
19298 else if(tmpscr->door[0]==dBOSS)
19299 {
19300 if(game->lvlitems[dlevel]&liBOSSKEY)
19301 {
19302 putdoor(scrollbuf,0,up,dOPENBOSS);
19303 tmpscr->door[0]=dOPENBOSS;
19304 setmapflag(si, mDOOR_UP);
19305
19306 if(di != 0xFFFF)
19307 setmapflag(di, mDOOR_DOWN);
19308 sfx(WAV_DOOR);
19309 markBmap(-1);
19310 // Run Boss Key Script
19311 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19312 for ( int32_t q = 0; q < MAXITEMS; ++q )
19313 {
19314 if ( itemsbuf[q].family == itype_bosskey )
19315 {
19316 key_item = q; break;
19317 }
19318 }
19319 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19320 {
19321 ri = &(itemScriptData[key_item]);
19322 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19323 ri->Clear();
19324 item_doscript[key_item] = 1;
19325 itemscriptInitialised[key_item] = 0;
19326 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19327 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19328 }
19329 }
19330 else return;
19331
19332 }
19333
19334 }
19335 }
19336 //Down
19337 if ( y >= 128 && x >= 112 && x <= 128 )
19338 {
19339 if ( dir == down || dir == l_down || dir == r_down ) //|| Down() || ( Down()&&Left()) || ( Down()&&Right()))
19340 {
19341 di = nextscr(down);
19342 if(tmpscr->door[1]==dLOCKED)
19343 {
19344 if(usekey())
19345 {
19346 putdoor(scrollbuf,0,down,dUNLOCKED);
19347 tmpscr->door[1]=dUNLOCKED;
19348 setmapflag(si, mDOOR_DOWN);
19349
19350 if(di != 0xFFFF)
19351 setmapflag(di, mDOOR_UP);
19352 sfx(WAV_DOOR);
19353 markBmap(-1);
19354 }
19355 else return;
19356 }
19357 else if(tmpscr->door[1]==dBOSS)
19358 {
19359 if(game->lvlitems[dlevel]&liBOSSKEY)
19360 {
19361 putdoor(scrollbuf,0,down,dOPENBOSS);
19362 tmpscr->door[1]=dOPENBOSS;
19363 setmapflag(si, mDOOR_DOWN);
19364
19365 if(di != 0xFFFF)
19366 setmapflag(di, mDOOR_UP);
19367 sfx(WAV_DOOR);
19368 markBmap(-1);
19369 // Run Boss Key Script
19370 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19371 for ( int32_t q = 0; q < MAXITEMS; ++q )
19372 {
19373 if ( itemsbuf[q].family == itype_bosskey )
19374 {
19375 key_item = q; break;
19376 }
19377 }
19378 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19379 {
19380 ri = &(itemScriptData[key_item]);
19381 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19382 ri->Clear();
19383 item_doscript[key_item] = 1;
19384 itemscriptInitialised[key_item] = 0;
19385 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19386 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19387 }
19388 }
19389 else return;
19390 }
19391 }
19392 }
19393 //left
19394 if ( y > 72 && y < 88 && x <= 32 )
19395 {
19396 if ( dir == left || dir == l_up || dir == l_down )//|| Left() || ( Up()&&Left()) || ( Down()&&Left() ) )
19397 {
19398 di = nextscr(left);
19399 if(tmpscr->door[2]==dLOCKED)
19400 {
19401 if(usekey())
19402 {
19403 putdoor(scrollbuf,0,left,dUNLOCKED);
19404 tmpscr->door[2]=dUNLOCKED;
19405 setmapflag(si, mDOOR_LEFT);
19406
19407 if(di != 0xFFFF)
19408 setmapflag(di, mDOOR_RIGHT);
19409 sfx(WAV_DOOR);
19410 markBmap(-1);
19411 }
19412 else return;
19413 }
19414 else if(tmpscr->door[2]==dBOSS)
19415 {
19416 if(game->lvlitems[dlevel]&liBOSSKEY)
19417 {
19418 putdoor(scrollbuf,0,left,dOPENBOSS);
19419 tmpscr->door[2]=dOPENBOSS;
19420 setmapflag(si, mDOOR_LEFT);
19421
19422 if(di != 0xFFFF)
19423 setmapflag(di, mDOOR_RIGHT);
19424 sfx(WAV_DOOR);
19425 markBmap(-1);
19426 // Run Boss Key Script
19427 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19428 for ( int32_t q = 0; q < MAXITEMS; ++q )
19429 {
19430 if ( itemsbuf[q].family == itype_bosskey )
19431 {
19432 key_item = q; break;
19433 }
19434 }
19435 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19436 {
19437 ri = &(itemScriptData[key_item]);
19438 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19439 ri->Clear();
19440 item_doscript[key_item] = 1;
19441 itemscriptInitialised[key_item] = 0;
19442 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19443 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19444 }
19445 }
19446 else return;
19447 }
19448 }
19449 }
19450
19451
19452 //right
19453 if ( ( y > 72 && y < 88 ) && x >= 208 )
19454 //!( (y<=72||y>=88) && x<206 ) )
19455 //y<=72||y>=88):y!=80) || x<208)
19456 {
19457 if ( dir == right || dir == r_up || dir == r_down ) //|| Right() || ( Down()&&Right() ) || ( Up()&&Right()))
19458 {
19459 di = nextscr(right);
19460 if(tmpscr->door[right]==dLOCKED)
19461 {
19462 if(usekey())
19463 {
19464 putdoor(scrollbuf,0,right,dUNLOCKED);
19465 tmpscr->door[3]=dUNLOCKED;
19466 setmapflag(si, mDOOR_RIGHT);
19467
19468 if(di != 0xFFFF)
19469 setmapflag(di, mDOOR_LEFT);
19470 sfx(WAV_DOOR);
19471 markBmap(-1);
19472 }
19473 else return;
19474 }
19475 else if(tmpscr->door[right]==dBOSS)
19476 {
19477 if(game->lvlitems[dlevel]&liBOSSKEY)
19478 {
19479 putdoor(scrollbuf,0,right,dOPENBOSS);
19480 tmpscr->door[3]=dOPENBOSS;
19481 setmapflag(si, mDOOR_RIGHT);
19482
19483 if(di != 0xFFFF)
19484 setmapflag(di, mDOOR_LEFT);
19485 sfx(WAV_DOOR);
19486 markBmap(-1);
19487 // Run Boss Key Script
19488 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19489 for ( int32_t q = 0; q < MAXITEMS; ++q )
19490 {
19491 if ( itemsbuf[q].family == itype_bosskey )
19492 {
19493 key_item = q; break;
19494 }
19495 }
19496 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19497 {
19498 ri = &(itemScriptData[key_item]);
19499 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19500 ri->Clear();
19501 item_doscript[key_item] = 1;
19502 itemscriptInitialised[key_item] = 0;
19503 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19504 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19505 }
19506 }
19507 else return;
19508 }
19509
19510 }
19511 }
19512 }
19513 else
19514 {
19515 //orthogonal movement
19516 //Up door
19517
4/4
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 587 times.
✓ Branch 2 taken 61 times.
✓ Branch 3 taken 83 times.
731 if ( y<=32 && x == 120 )
19518 //!( y>32 && (x!=120) ))
19519 {
19520
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 1 times.
83 switch ( dir )
19521 {
19522 case up:
19523 case r_up:
19524 case l_up:
19525 {
19526 82 di = nextscr(up);
19527
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 22 times.
82 if(tmpscr->door[0]==dLOCKED)
19528 {
19529
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 3 times.
60 if(usekey())
19530 {
19531 57 putdoor(scrollbuf,0,up,dUNLOCKED);
19532 57 tmpscr->door[0]=dUNLOCKED;
19533 57 setmapflag(si, mDOOR_UP);
19534
19535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(di != 0xFFFF)
19536 57 setmapflag(di, mDOOR_DOWN);
19537 57 sfx(WAV_DOOR);
19538 57 markBmap(-1);
19539 57 }
19540 3 else return;
19541 57 }
19542
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 15 times.
22 else if(tmpscr->door[0]==dBOSS)
19543 {
19544
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1 times.
15 if(game->lvlitems[dlevel]&liBOSSKEY)
19545 {
19546 14 putdoor(scrollbuf,0,up,dOPENBOSS);
19547 14 tmpscr->door[0]=dOPENBOSS;
19548 14 setmapflag(si, mDOOR_UP);
19549
19550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(di != 0xFFFF)
19551 14 setmapflag(di, mDOOR_DOWN);
19552 14 sfx(WAV_DOOR);
19553 14 markBmap(-1);
19554 // Run Boss Key Script
19555 14 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 952 times.
952 for ( int32_t q = 0; q < MAXITEMS; ++q )
19557 {
19558
2/2
✓ Branch 0 taken 938 times.
✓ Branch 1 taken 14 times.
952 if ( itemsbuf[q].family == itype_bosskey )
19559 {
19560 14 key_item = q; break;
19561 }
19562 938 }
19563
2/8
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19564 {
19565 ri = &(itemScriptData[key_item]);
19566 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19567 ri->Clear();
19568 item_doscript[key_item] = 1;
19569 itemscriptInitialised[key_item] = 0;
19570 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19571 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19572 }
19573 14 }
19574 1 else return;
19575 14 }
19576 78 break;
19577 }
19578 1 default: break;
19579
19580 }
19581 79 }
19582 //Down
19583
4/4
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 638 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 23 times.
727 if ( y >= 128 && x == 120 )
19584 //!(y<128 && (x!=120) ) )
19585 {
19586
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 3 times.
23 switch(dir)
19587 {
19588 case down:
19589 case l_down:
19590 case r_down:
19591 {
19592 20 di = nextscr(down);
19593
19594
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 9 times.
20 if(tmpscr->door[1]==dLOCKED)
19595 {
19596
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
11 if(usekey())
19597 {
19598 10 putdoor(scrollbuf,0,down,dUNLOCKED);
19599 10 tmpscr->door[1]=dUNLOCKED;
19600 10 setmapflag(si, mDOOR_DOWN);
19601
19602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(di != 0xFFFF)
19603 10 setmapflag(di, mDOOR_UP);
19604 10 sfx(WAV_DOOR);
19605 10 markBmap(-1);
19606 10 }
19607 1 else return;
19608 10 }
19609
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 5 times.
9 else if(tmpscr->door[1]==dBOSS)
19610 {
19611
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 if(game->lvlitems[dlevel]&liBOSSKEY)
19612 {
19613 4 putdoor(scrollbuf,0,down,dOPENBOSS);
19614 4 tmpscr->door[1]=dOPENBOSS;
19615 4 setmapflag(si, mDOOR_DOWN);
19616
19617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(di != 0xFFFF)
19618 4 setmapflag(di, mDOOR_UP);
19619 4 sfx(WAV_DOOR);
19620 4 markBmap(-1);
19621 // Run Boss Key Script
19622 4 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 272 times.
272 for ( int32_t q = 0; q < MAXITEMS; ++q )
19624 {
19625
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 4 times.
272 if ( itemsbuf[q].family == itype_bosskey )
19626 {
19627 4 key_item = q; break;
19628 }
19629 268 }
19630
2/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19631 {
19632 ri = &(itemScriptData[key_item]);
19633 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19634 ri->Clear();
19635 item_doscript[key_item] = 1;
19636 itemscriptInitialised[key_item] = 0;
19637 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19638 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19639 }
19640 4 }
19641 1 else return;
19642 4 }
19643 18 break;
19644 }
19645 3 default: break;
19646 }
19647 21 }
19648 //left
19649
4/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 588 times.
✓ Branch 2 taken 97 times.
✓ Branch 3 taken 40 times.
725 if ( y == 80 && x <= 32 )
19650 //!( (y!=80) && x>32 ) )
19651 {
19652
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 7 times.
40 switch(dir)
19653 {
19654 case left:
19655 case l_up:
19656 case l_down:
19657 {
19658 33 di = nextscr(left);
19659
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 11 times.
33 if(tmpscr->door[2]==dLOCKED)
19660 {
19661
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1 times.
22 if(usekey())
19662 {
19663 21 putdoor(scrollbuf,0,left,dUNLOCKED);
19664 21 tmpscr->door[2]=dUNLOCKED;
19665 21 setmapflag(si, mDOOR_LEFT);
19666
19667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(di != 0xFFFF)
19668 21 setmapflag(di, mDOOR_RIGHT);
19669 21 sfx(WAV_DOOR);
19670 21 markBmap(-1);
19671 21 }
19672 1 else return;
19673 21 }
19674
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5 times.
11 else if(tmpscr->door[2]==dBOSS)
19675 {
19676
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 if(game->lvlitems[dlevel]&liBOSSKEY)
19677 {
19678 4 putdoor(scrollbuf,0,left,dOPENBOSS);
19679 4 tmpscr->door[2]=dOPENBOSS;
19680 4 setmapflag(si, mDOOR_LEFT);
19681
19682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(di != 0xFFFF)
19683 4 setmapflag(di, mDOOR_RIGHT);
19684 4 sfx(WAV_DOOR);
19685 4 markBmap(-1);
19686 // Run Boss Key Script
19687 4 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 272 times.
272 for ( int32_t q = 0; q < MAXITEMS; ++q )
19689 {
19690
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 4 times.
272 if ( itemsbuf[q].family == itype_bosskey )
19691 {
19692 4 key_item = q; break;
19693 }
19694 268 }
19695
2/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19696 {
19697 ri = &(itemScriptData[key_item]);
19698 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19699 ri->Clear();
19700 item_doscript[key_item] = 1;
19701 itemscriptInitialised[key_item] = 0;
19702 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19703 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19704 }
19705 4 }
19706 1 else return;
19707 4 }
19708
19709 31 break;
19710
19711 }
19712 7 default: break;
19713 }
19714 38 }
19715 //right
19716
4/4
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 588 times.
✓ Branch 2 taken 86 times.
✓ Branch 3 taken 49 times.
723 if ( y == 80 && x >= 208 )
19717 //!((y!=80) && x<208 ) )
19718 {
19719
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 2 times.
49 switch(dir)
19720 {
19721 case right:
19722 case r_down:
19723 case r_up:
19724 {
19725 47 di = nextscr(right);
19726
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 17 times.
47 if(tmpscr->door[3]==dLOCKED)
19727 {
19728
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(usekey())
19729 {
19730 30 putdoor(scrollbuf,0,right,dUNLOCKED);
19731 30 tmpscr->door[3]=dUNLOCKED;
19732 30 setmapflag(si, mDOOR_RIGHT);
19733
19734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(di != 0xFFFF)
19735 30 setmapflag(di, mDOOR_LEFT);
19736 30 sfx(WAV_DOOR);
19737 30 markBmap(-1);
19738 30 }
19739 else return;
19740 30 }
19741
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
17 else if(tmpscr->door[3]==dBOSS)
19742 {
19743
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 if(game->lvlitems[dlevel]&liBOSSKEY)
19744 {
19745 7 putdoor(scrollbuf,0,right,dOPENBOSS);
19746 7 tmpscr->door[3]=dOPENBOSS;
19747 7 setmapflag(si, mDOOR_RIGHT);
19748
19749
19750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(di != 0xFFFF)
19751 7 setmapflag(di, mDOOR_LEFT);
19752 7 sfx(WAV_DOOR);
19753 7 markBmap(-1);
19754 // Run Boss Key Script
19755 7 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 476 times.
476 for ( int32_t q = 0; q < MAXITEMS; ++q )
19757 {
19758
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 7 times.
476 if ( itemsbuf[q].family == itype_bosskey )
19759 {
19760 7 key_item = q; break;
19761 }
19762 469 }
19763
2/8
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) ) //
19764 {
19765 ri = &(itemScriptData[key_item]);
19766 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19767 ri->Clear();
19768 item_doscript[key_item] = 1;
19769 itemscriptInitialised[key_item] = 0;
19770 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19771 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19772 }
19773
19774 7 }
19775 1 else return;
19776 7 }
19777
19778
19779 46 break;
19780 }
19781 2 default: break;
19782
19783 }
19784 48 }
19785 }
19786 3391281 }
19787
19788 3391281 void HeroClass::checkswordtap()
19789 {
19790
6/6
✓ Branch 0 taken 1920246 times.
✓ Branch 1 taken 1471035 times.
✓ Branch 2 taken 1913 times.
✓ Branch 3 taken 1918333 times.
✓ Branch 4 taken 1902 times.
✓ Branch 5 taken 11 times.
3391281 if(attack!=wSword || charging<=0 || pushing<8) return;
19791
19792 11 int32_t bx=x;
19793 11 int32_t by=y+8;
19794
19795
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
11 switch(dir)
19796 {
19797 case up:
19798
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!Up()) return;
19799
19800 11 by-=16;
19801 11 break;
19802
19803 case down:
19804 if(!Down()) return;
19805
19806 by+=16;
19807 bx+=8;
19808 break;
19809
19810 case left:
19811 if(!Left()) return;
19812
19813 bx-=16;
19814 by+=8;
19815 break;
19816
19817 case right:
19818 if(!Right()) return;
19819
19820 bx+=16;
19821 by+=8;
19822 break;
19823 }
19824
19825
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
11 if(!_walkflag(bx,by,0,SWITCHBLOCK_STATE)) return;
19826
19827 11 attackclk=SWORDTAPFRAME;
19828 11 pushing=-8; //16 frames between taps
19829 11 tapping=true;
19830
19831 11 int32_t type = COMBOTYPE(bx,by);
19832
19833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!isCuttableType(type))
19834 {
19835
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
22 bool hollow = (MAPFLAG(bx,by) == mfBOMB || MAPCOMBOFLAG(bx,by) == mfBOMB ||
19836
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 MAPFLAG(bx,by) == mfSBOMB || MAPCOMBOFLAG(bx,by) == mfSBOMB);
19837
19838 // Layers
19839
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 11 times.
77 for(int32_t i=0; i < 6; i++)
19840
3/6
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
132 hollow = (hollow || MAPFLAG2(i,bx,by) == mfBOMB || MAPCOMBOFLAG2(i,bx,by) == mfBOMB ||
19841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 MAPFLAG2(i,bx,by) == mfSBOMB || MAPCOMBOFLAG2(i,bx,by) == mfSBOMB);
19842
19843
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t i=0; i<4; i++)
19844
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44 if(tmpscr->door[i]==dBOMB && i==dir)
19845 switch(i)
19846 {
19847 case up:
19848 case down:
19849 if(bx>=112 && bx<144 && (by>=144 || by<=32)) hollow=true;
19850
19851 break;
19852
19853 case left:
19854 case right:
19855 if(by>=72 && by<104 && (bx>=224 || bx<=32)) hollow=true;
19856
19857 break;
19858 }
19859
19860 11 sfx(hollow ? WAV_ZN1TAP2 : WAV_ZN1TAP,pan(x.getInt()));
19861 11 }
19862
19863 3391281 }
19864
19865 13458 void HeroClass::fairycircle(int32_t type)
19866 {
19867
2/2
✓ Branch 0 taken 11551 times.
✓ Branch 1 taken 1907 times.
13458 if(fairyclk==0)
19868 {
19869
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1907 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1907 switch(type)
19870 {
19871 case REFILL_LIFE:
19872
2/2
✓ Branch 0 taken 1836 times.
✓ Branch 1 taken 71 times.
1907 if(didstuff&did_fairy) return;
19873
19874 71 didstuff|=did_fairy;
19875 71 break;
19876
19877 case REFILL_MAGIC:
19878 if(didstuff&did_magic) return;
19879
19880 didstuff|=did_magic;
19881 break;
19882
19883 case REFILL_ALL:
19884 if(didstuff&did_all) return;
19885
19886 didstuff|=did_all;
19887 }
19888
19889 71 refill_what=type;
19890 71 refill_why=REFILL_FAIRY;
19891 71 StartRefill(type);
19892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
19893 71 else {action=freeze; FFCore.setHeroAction(freeze);}
19894 71 holdclk=0;
19895 71 hopclk=0;
19896 71 }
19897
19898 11622 ++fairyclk;
19899
19900
2/2
✓ Branch 0 taken 5871 times.
✓ Branch 1 taken 5751 times.
11622 if(refilling!=REFILL_FAIRYDONE)
19901 {
19902
2/2
✓ Branch 0 taken 5800 times.
✓ Branch 1 taken 71 times.
5871 if(!refill())
19903 71 refilling=REFILL_FAIRYDONE;
19904 5871 }
19905
19906
2/2
✓ Branch 0 taken 5680 times.
✓ Branch 1 taken 71 times.
5751 else if(++holdclk>80)
19907 {
19908 71 reset_swordcharge();
19909 71 attackclk=0;
19910 71 action=none; FFCore.setHeroAction(none);
19911 71 fairyclk=0;
19912 71 holdclk=0;
19913 71 refill_why = 0;
19914 71 refilling=REFILL_NONE;
19915 71 map_bkgsfx(true);
19916 71 }
19917 13458 }
19918
19919 233595 int32_t touchcombo(int32_t x,int32_t y)
19920 {
19921
2/2
✓ Branch 0 taken 467190 times.
✓ Branch 1 taken 233595 times.
700785 for (int32_t i = 0; i <= 1; ++i)
19922 {
19923
2/2
✓ Branch 0 taken 377288 times.
✓ Branch 1 taken 89902 times.
467190 if(tmpscr2[i].valid!=0)
19924 {
19925
2/2
✓ Branch 0 taken 84571 times.
✓ Branch 1 taken 5331 times.
89902 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19926 {
19927
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84571 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84571 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && !_walkflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
19928 84571 }
19929 else
19930 {
19931
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5331 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5331 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && _effectflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
19932 }
19933 89902 }
19934 467190 }
19935
2/2
✓ Branch 0 taken 233148 times.
✓ Branch 1 taken 447 times.
233595 if (!_effectflag(x,y,1, -1)) return 0;
19936 233148 newcombo const& cmb = combobuf[MAPCOMBO(x,y)];
19937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233148 times.
233148 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
19938 return 0;
19939
3/3
✓ Branch 0 taken 2743 times.
✓ Branch 1 taken 229118 times.
✓ Branch 2 taken 1287 times.
233148 switch(cmb.type)
19940 {
19941 case cBSGRAVE:
19942 case cGRAVE:
19943
3/4
✓ Branch 0 taken 1814 times.
✓ Branch 1 taken 929 times.
✓ Branch 2 taken 1814 times.
✗ Branch 3 not taken.
2743 if(MAPFLAG(x,y)||MAPCOMBOFLAG(x,y)) //!DIMITODO: all flags break graves, not just push flags
19944 {
19945 929 break;
19946 }
19947
19948 [[fallthrough]];
19949 case cARMOS:
19950 {
19951 3101 return cmb.type;
19952 }
19953 }
19954
19955 230047 return 0;
19956 233595 }
19957
19958 //static int32_t COMBOX(int32_t pos) { return ((pos)%16*16); }
19959 //static int32_t COMBOY(int32_t pos) { return ((pos)&0xF0); }
19960
19961 static int32_t GridX(int32_t x)
19962 {
19963 return (x >> 4) << 4;
19964 }
19965
19966 //Snaps 'y' to the combo grid
19967 //Equivalent to calling ComboY(ComboAt(foo,y));
19968 static int32_t GridY(int32_t y)
19969 {
19970 return (y >> 4) << 4;
19971 }
19972
19973 int32_t grabComboFromPos(int32_t pos, int32_t type)
19974 {
19975 for(int32_t lyr = 6; lyr > -1; --lyr)
19976 {
19977 int32_t id = FFCore.tempScreens[lyr]->data[pos];
19978 if(combobuf[id].type == type)
19979 return id;
19980 }
19981 return -1;
19982 }
19983
19984 static int32_t typeMap[176];
19985 static int32_t istrig[176];
19986 static const int32_t SPTYPE_SOLID = -1;
19987 #define SP_VISITED 0x1
19988 #define SPFLAG(dir) (0x2<<dir)
19989 #define BEAM_AGE_LIMIT 32
19990 void HeroClass::handleBeam(byte* grid, size_t age, byte spotdir, int32_t curpos, byte set, bool block, bool refl)
19991 {
19992 int32_t trigflag = set ? (1 << (set-1)) : ~0;
19993 if(spotdir > 3) return; //invalid dir
19994 bool doAge = true;
19995 byte f = 0;
19996 while(unsigned(curpos) < 176)
19997 {
19998 bool block_light = false;
19999 f = SPFLAG(spotdir);
20000 if((grid[curpos] & f) != f)
20001 {
20002 grid[curpos] |= f;
20003 istrig[curpos] |= trigflag;
20004 doAge = false;
20005 age = 0;
20006 }
20007 switch(spotdir)
20008 {
20009 case up:
20010 curpos -= 0x10;
20011 break;
20012 case down:
20013 curpos += 0x10;
20014 break;
20015 case left:
20016 if(!(curpos%0x10))
20017 curpos = -1;
20018 else --curpos;
20019 break;
20020 case right:
20021 ++curpos;
20022 if(!(curpos%0x10))
20023 curpos = -1;
20024 break;
20025 }
20026 if(unsigned(curpos) >= 176) break;
20027 switch(typeMap[curpos])
20028 {
20029 case SPTYPE_SOLID: case cBLOCKALL:
20030 curpos = -1;
20031 break;
20032 }
20033 if((curpos==COMBOPOS(x.getInt()+8,y.getInt()+8)) && block && (spotdir == oppositeDir[dir]))
20034 curpos = -1;
20035 if(unsigned(curpos) >= 176) break;
20036
20037 f = SPFLAG(oppositeDir[spotdir]);
20038 if((grid[curpos] & f) != f)
20039 {
20040 grid[curpos] |= f;
20041 istrig[curpos] |= trigflag;
20042 doAge = false;
20043 age = 0;
20044 }
20045 if(doAge)
20046 {
20047 if(++age > BEAM_AGE_LIMIT)
20048 break;
20049 }
20050 else doAge = true;
20051
20052 if(curpos==COMBOPOS(x.getInt()+8,y.getInt() +8) && refl)
20053 spotdir = dir;
20054 else switch(typeMap[curpos])
20055 {
20056 case cLIGHTTARGET:
20057 if(combobuf[grabComboFromPos(curpos, cLIGHTTARGET)].usrflags&cflag3) //Blocks light
20058 return;
20059 case cMIRROR:
20060 spotdir = oppositeDir[spotdir];
20061 break;
20062 case cMIRRORSLASH:
20063 switch(spotdir)
20064 {
20065 case up:
20066 spotdir = right; break;
20067 case right:
20068 spotdir = up; break;
20069 case down:
20070 spotdir = left; break;
20071 case left:
20072 spotdir = down; break;
20073 }
20074 break;
20075 case cMIRRORBACKSLASH:
20076 switch(spotdir)
20077 {
20078 case up:
20079 spotdir = left; break;
20080 case left:
20081 spotdir = up; break;
20082 case down:
20083 spotdir = right; break;
20084 case right:
20085 spotdir = down; break;
20086 }
20087 break;
20088 case cMAGICPRISM:
20089 for(byte d = 0; d < 4; ++d)
20090 {
20091 if(d == oppositeDir[spotdir]) continue;
20092 handleBeam(grid, age, d, curpos, set, block, refl);
20093 }
20094 return;
20095 case cMAGICPRISM4:
20096 for(byte d = 0; d < 4; ++d)
20097 {
20098 handleBeam(grid, age, d, curpos, set, block, refl);
20099 }
20100 return;
20101 }
20102 }
20103 }
20104
20105 3394919 void HeroClass::handleSpotlights()
20106 {
20107 typedef byte spot_t;
20108 //Store each different tile/color as grids
20109 3394919 std::map<int32_t, spot_t*> maps;
20110
1/2
✓ Branch 0 taken 3394919 times.
✗ Branch 1 not taken.
3394919 int32_t shieldid = getCurrentShield(false);
20111
2/2
✓ Branch 0 taken 3138177 times.
✓ Branch 1 taken 256742 times.
3394919 bool refl = shieldid > -1 && (itemsbuf[shieldid].misc2 & shLIGHTBEAM);
20112
3/4
✓ Branch 0 taken 3394919 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256742 times.
✓ Branch 3 taken 3138177 times.
3394919 bool block = !refl && shieldid > -1 && (itemsbuf[shieldid].misc1 & shLIGHTBEAM);
20113
3/6
✓ Branch 0 taken 3394919 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3394919 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3394919 times.
✗ Branch 5 not taken.
3394919 int32_t heropos = COMBOPOS(x.getInt()+8,y.getInt()+8);
20114 3394919 memset(istrig, 0, sizeof(istrig));
20115
1/2
✓ Branch 0 taken 3394919 times.
✗ Branch 1 not taken.
3394919 clear_bitmap(lightbeam_bmp);
20116
20117
2/2
✓ Branch 0 taken 597505744 times.
✓ Branch 1 taken 3394919 times.
600900663 for(size_t pos = 0; pos < 176; ++pos)
20118 {
20119 597505744 typeMap[pos] = 0;
20120
2/2
✓ Branch 0 taken 597333625 times.
✓ Branch 1 taken 4182539723 times.
4779873348 for(int32_t lyr = 6; lyr > -1; --lyr)
20121 {
20122 4182539723 newcombo const* cmb = &combobuf[FFCore.tempScreens[lyr]->data[pos]];
20123
2/3
✓ Branch 0 taken 172119 times.
✓ Branch 1 taken 4182367604 times.
✗ Branch 2 not taken.
4182539723 switch(cmb->type)
20124 {
20125 case cMIRROR: case cMIRRORSLASH: case cMIRRORBACKSLASH:
20126 case cMAGICPRISM: case cMAGICPRISM4:
20127 case cBLOCKALL: case cLIGHTTARGET:
20128 172119 typeMap[pos] = cmb->type;
20129 172119 break;
20130 case cGLASS:
20131 typeMap[pos] = 0;
20132 break;
20133 default:
20134 {
20135
4/4
✓ Branch 0 taken 1792344628 times.
✓ Branch 1 taken 2390022976 times.
✓ Branch 2 taken 1429278611 times.
✓ Branch 3 taken 363066017 times.
4182367604 if(lyr < 3 && (cmb->walk & 0xF))
20136 {
20137 363066017 typeMap[pos] = SPTYPE_SOLID;
20138 363066017 }
20139 4182367604 continue; //next layer
20140 }
20141 }
20142 172119 break; //hit a combo type
20143 }
20144 597505744 }
20145
2/2
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 3394789 times.
3394919 if(unsigned(heropos) < 176)
20146 {
20147
2/2
✓ Branch 0 taken 278265 times.
✓ Branch 1 taken 3116524 times.
3394789 switch(typeMap[heropos])
20148 {
20149 case SPTYPE_SOLID: case cBLOCKALL:
20150 278265 heropos = -1; //Blocked from hitting player
20151 278265 }
20152 3394789 }
20153
20154
2/2
✓ Branch 0 taken 23764433 times.
✓ Branch 1 taken 3394919 times.
27159352 for(size_t layer = 0; layer < 7; ++layer)
20155 {
20156 23764433 mapscr* curlayer = FFCore.tempScreens[layer];
20157
2/2
✓ Branch 0 taken 4182540208 times.
✓ Branch 1 taken 23764433 times.
4206304641 for(size_t pos = 0; pos < 176; ++pos)
20158 {
20159 //For each spotlight combo on each layer...
20160 4182540208 newcombo const& cmb = combobuf[curlayer->data[pos]];
20161
1/2
✓ Branch 0 taken 4182540208 times.
✗ Branch 1 not taken.
4182540208 if(cmb.type == cSPOTLIGHT)
20162 {
20163 //Positive ID is a tile, negative is a color trio. 0 is nil in either case.
20164 int32_t id = (cmb.usrflags&cflag1)
20165 ? std::max(0,cmb.attributes[0]/10000)|(cmb.attribytes[1]%12)<<24
20166 : -((cmb.attribytes[3]<<16)|(cmb.attribytes[2]<<8)|(cmb.attribytes[1]));
20167 if(!id) continue;
20168 // zprint2("ID = %ld\n", id);
20169 //Get the grid array for this tile/color
20170 spot_t* grid;
20171 if(maps[id])
20172 grid = maps[id];
20173 else
20174 {
20175 grid = new spot_t[176];
20176 memset(grid, 0, sizeof(spot_t)*176);
20177 maps[id] = grid;
20178 }
20179 byte spotdir = cmb.attribytes[0];
20180 int32_t curpos = pos;
20181 if(spotdir > 3)
20182 {
20183 grid[curpos] |= SP_VISITED;
20184 istrig[curpos] |= cmb.attribytes[4] ? (1 << (cmb.attribytes[4]-1)) : ~0;
20185 }
20186 if(refl && curpos == heropos)
20187 {
20188 spotdir = dir;
20189 }
20190 handleBeam(grid, 0, spotdir, curpos, cmb.attribytes[4], block, refl);
20191 }
20192 4182540208 }
20193 23764433 }
20194
20195 //Draw visuals
20196
1/2
✓ Branch 0 taken 3394919 times.
✗ Branch 1 not taken.
3394919 for(auto it = maps.begin(); it != maps.end();)
20197 {
20198 int32_t id = it->first;
20199 spot_t* grid = it->second;
20200 //
20201 enum {t_gr, t_up, t_down, t_left, t_right, t_uleft, t_uright, t_dleft, t_dright, t_vert, t_horz, t_notup, t_notdown, t_notleft, t_notright, t_all, t_max };
20202 int32_t tile = (id&0xFFFFFF);
20203 int32_t cs = (id>>24);
20204 byte c_inner = ((-id)&0x0000FF);
20205 byte c_middle = ((-id)&0x00FF00)>>8;
20206 byte c_outter = ((-id)&0xFF0000)>>16;
20207 //{ Setup color bitmap
20208 BITMAP* cbmp = NULL;
20209 if(id < 0)
20210 {
20211 //zprint2("Creating with colors: %02X,%02X,%02X\n", c_inner, c_middle, c_outter);
20212 cbmp = create_bitmap_ex(8, 16*t_max, 16);
20213 clear_bitmap(cbmp);
20214 for(size_t q = 1; q < t_max; ++q)
20215 {
20216 circlefill(cbmp, 16*q+8, 8, 3, c_outter);
20217 circlefill(cbmp, 16*q+7, 8, 3, c_outter);
20218 circlefill(cbmp, 16*q+8, 7, 3, c_outter);
20219 circlefill(cbmp, 16*q+7, 7, 3, c_outter);
20220 circlefill(cbmp, 16*q+8, 8, 1, c_middle);
20221 circlefill(cbmp, 16*q+7, 8, 1, c_middle);
20222 circlefill(cbmp, 16*q+8, 7, 1, c_middle);
20223 circlefill(cbmp, 16*q+7, 7, 1, c_middle);
20224 circlefill(cbmp, 16*q+8, 8, 0, c_inner);
20225 circlefill(cbmp, 16*q+7, 8, 0, c_inner);
20226 circlefill(cbmp, 16*q+8, 7, 0, c_inner);
20227 circlefill(cbmp, 16*q+7, 7, 0, c_inner);
20228 }
20229 //t_gr
20230 circlefill(cbmp, 16*t_gr+8, 8, 7, c_outter);
20231 circlefill(cbmp, 16*t_gr+7, 8, 7, c_outter);
20232 circlefill(cbmp, 16*t_gr+8, 7, 7, c_outter);
20233 circlefill(cbmp, 16*t_gr+7, 7, 7, c_outter);
20234 circlefill(cbmp, 16*t_gr+8, 8, 5, c_middle);
20235 circlefill(cbmp, 16*t_gr+7, 8, 5, c_middle);
20236 circlefill(cbmp, 16*t_gr+8, 7, 5, c_middle);
20237 circlefill(cbmp, 16*t_gr+7, 7, 5, c_middle);
20238 circlefill(cbmp, 16*t_gr+8, 8, 3, c_inner);
20239 circlefill(cbmp, 16*t_gr+7, 8, 3, c_inner);
20240 circlefill(cbmp, 16*t_gr+8, 7, 3, c_inner);
20241 circlefill(cbmp, 16*t_gr+7, 7, 3, c_inner);
20242 //t_up
20243 rectfill(cbmp, 16*t_up+4, 0, 16*t_up+11, 7, c_outter);
20244 rectfill(cbmp, 16*t_up+6, 0, 16*t_up+9, 7, c_middle);
20245 rectfill(cbmp, 16*t_up+7, 0, 16*t_up+8, 7, c_inner);
20246 //t_down
20247 rectfill(cbmp, 16*t_down+4, 8, 16*t_down+11, 15, c_outter);
20248 rectfill(cbmp, 16*t_down+6, 8, 16*t_down+9, 15, c_middle);
20249 rectfill(cbmp, 16*t_down+7, 8, 16*t_down+8, 15, c_inner);
20250 //t_left
20251 rectfill(cbmp, 16*t_left, 4, 16*t_left+7, 11, c_outter);
20252 rectfill(cbmp, 16*t_left, 6, 16*t_left+7, 9, c_middle);
20253 rectfill(cbmp, 16*t_left, 7, 16*t_left+7, 8, c_inner);
20254 //t_right
20255 rectfill(cbmp, 16*t_right+8, 4, 16*t_right+15, 11, c_outter);
20256 rectfill(cbmp, 16*t_right+8, 6, 16*t_right+15, 9, c_middle);
20257 rectfill(cbmp, 16*t_right+8, 7, 16*t_right+15, 8, c_inner);
20258 //t_uleft
20259 rectfill(cbmp, 16*t_uleft+4, 0, 16*t_uleft+11, 7, c_outter);
20260 rectfill(cbmp, 16*t_uleft, 4, 16*t_uleft+7, 11, c_outter);
20261 rectfill(cbmp, 16*t_uleft, 6, 16*t_uleft+7, 9, c_middle);
20262 rectfill(cbmp, 16*t_uleft+6, 0, 16*t_uleft+9, 7, c_middle);
20263 rectfill(cbmp, 16*t_uleft+7, 0, 16*t_uleft+8, 7, c_inner);
20264 rectfill(cbmp, 16*t_uleft, 7, 16*t_uleft+7, 8, c_inner);
20265 //t_uright
20266 rectfill(cbmp, 16*t_uright+4, 0, 16*t_uright+11, 7, c_outter);
20267 rectfill(cbmp, 16*t_uright+8, 4, 16*t_uright+15, 11, c_outter);
20268 rectfill(cbmp, 16*t_uright+8, 6, 16*t_uright+15, 9, c_middle);
20269 rectfill(cbmp, 16*t_uright+6, 0, 16*t_uright+9, 7, c_middle);
20270 rectfill(cbmp, 16*t_uright+7, 0, 16*t_uright+8, 7, c_inner);
20271 rectfill(cbmp, 16*t_uright+8, 7, 16*t_uright+15, 8, c_inner);
20272 //t_dleft
20273 rectfill(cbmp, 16*t_dleft+4, 8, 16*t_dleft+11, 15, c_outter);
20274 rectfill(cbmp, 16*t_dleft, 4, 16*t_dleft+7, 11, c_outter);
20275 rectfill(cbmp, 16*t_dleft, 6, 16*t_dleft+7, 9, c_middle);
20276 rectfill(cbmp, 16*t_dleft+6, 8, 16*t_dleft+9, 15, c_middle);
20277 rectfill(cbmp, 16*t_dleft+7, 8, 16*t_dleft+8, 15, c_inner);
20278 rectfill(cbmp, 16*t_dleft, 7, 16*t_dleft+7, 8, c_inner);
20279 //t_dright
20280 rectfill(cbmp, 16*t_dright+4, 8, 16*t_dright+11, 15, c_outter);
20281 rectfill(cbmp, 16*t_dright+8, 4, 16*t_dright+15, 11, c_outter);
20282 rectfill(cbmp, 16*t_dright+8, 6, 16*t_dright+15, 9, c_middle);
20283 rectfill(cbmp, 16*t_dright+6, 8, 16*t_dright+9, 15, c_middle);
20284 rectfill(cbmp, 16*t_dright+7, 8, 16*t_dright+8, 15, c_inner);
20285 rectfill(cbmp, 16*t_dright+8, 7, 16*t_dright+15, 8, c_inner);
20286 //t_vert
20287 rectfill(cbmp, 16*t_vert+4, 0, 16*t_vert+11, 15, c_outter);
20288 rectfill(cbmp, 16*t_vert+6, 0, 16*t_vert+9, 15, c_middle);
20289 rectfill(cbmp, 16*t_vert+7, 0, 16*t_vert+8, 15, c_inner);
20290 //t_horz
20291 rectfill(cbmp, 16*t_horz, 4, 16*t_horz+15, 11, c_outter);
20292 rectfill(cbmp, 16*t_horz, 6, 16*t_horz+15, 9, c_middle);
20293 rectfill(cbmp, 16*t_horz, 7, 16*t_horz+15, 8, c_inner);
20294 //t_notup
20295 rectfill(cbmp, 16*t_notup, 4, 16*t_notup+15, 11, c_outter);
20296 rectfill(cbmp, 16*t_notup+4, 8, 16*t_notup+11, 15, c_outter);
20297 rectfill(cbmp, 16*t_notup+6, 8, 16*t_notup+9, 15, c_middle);
20298 rectfill(cbmp, 16*t_notup, 6, 16*t_notup+15, 9, c_middle);
20299 rectfill(cbmp, 16*t_notup, 7, 16*t_notup+15, 8, c_inner);
20300 rectfill(cbmp, 16*t_notup+7, 8, 16*t_notup+8, 15, c_inner);
20301 //t_notdown
20302 rectfill(cbmp, 16*t_notdown, 4, 16*t_notdown+15, 11, c_outter);
20303 rectfill(cbmp, 16*t_notdown+4, 0, 16*t_notdown+11, 7, c_outter);
20304 rectfill(cbmp, 16*t_notdown+6, 0, 16*t_notdown+9, 7, c_middle);
20305 rectfill(cbmp, 16*t_notdown, 6, 16*t_notdown+15, 9, c_middle);
20306 rectfill(cbmp, 16*t_notdown, 7, 16*t_notdown+15, 8, c_inner);
20307 rectfill(cbmp, 16*t_notdown+7, 0, 16*t_notdown+8, 7, c_inner);
20308 //t_notleft
20309 rectfill(cbmp, 16*t_notleft+4, 0, 16*t_notleft+11, 15, c_outter);
20310 rectfill(cbmp, 16*t_notleft+8, 4, 16*t_notleft+15, 11, c_outter);
20311 rectfill(cbmp, 16*t_notleft+8, 6, 16*t_notleft+15, 9, c_middle);
20312 rectfill(cbmp, 16*t_notleft+6, 0, 16*t_notleft+9, 15, c_middle);
20313 rectfill(cbmp, 16*t_notleft+7, 0, 16*t_notleft+8, 15, c_inner);
20314 rectfill(cbmp, 16*t_notleft+8, 7, 16*t_notleft+15, 8, c_inner);
20315 //t_notright
20316 rectfill(cbmp, 16*t_notright+4, 0, 16*t_notright+11, 15, c_outter);
20317 rectfill(cbmp, 16*t_notright, 4, 16*t_notright+7, 11, c_outter);
20318 rectfill(cbmp, 16*t_notright, 6, 16*t_notright+7, 9, c_middle);
20319 rectfill(cbmp, 16*t_notright+6, 0, 16*t_notright+9, 15, c_middle);
20320 rectfill(cbmp, 16*t_notright+7, 0, 16*t_notright+8, 15, c_inner);
20321 rectfill(cbmp, 16*t_notright, 7, 16*t_notright+7, 8, c_inner);
20322 //t_all
20323 rectfill(cbmp, 16*t_all+4, 0, 16*t_all+11, 15, c_outter);
20324 rectfill(cbmp, 16*t_all, 4, 16*t_all+15, 11, c_outter);
20325 rectfill(cbmp, 16*t_all, 6, 16*t_all+15, 9, c_middle);
20326 rectfill(cbmp, 16*t_all+6, 0, 16*t_all+9, 15, c_middle);
20327 rectfill(cbmp, 16*t_all+7, 0, 16*t_all+8, 15, c_inner);
20328 rectfill(cbmp, 16*t_all, 7, 16*t_all+15, 8, c_inner);
20329 }
20330 //}
20331 //
20332 for(size_t pos = 0; pos < 176; ++pos)
20333 {
20334 int32_t offs = -1;
20335 switch(grid[pos]>>1)
20336 {
20337 case 0: default:
20338 if(grid[pos])
20339 {
20340 offs = t_gr;
20341 break;
20342 }
20343 continue; //no draw this pos
20344 case 0b0001:
20345 offs = t_up;
20346 break;
20347 case 0b0010:
20348 offs = t_down;
20349 break;
20350 case 0b0100:
20351 offs = t_left;
20352 break;
20353 case 0b1000:
20354 offs = t_right;
20355 break;
20356 case 0b0011:
20357 offs = t_vert;
20358 break;
20359 case 0b1100:
20360 offs = t_horz;
20361 break;
20362 case 0b0101:
20363 offs = t_uleft;
20364 break;
20365 case 0b1001:
20366 offs = t_uright;
20367 break;
20368 case 0b0110:
20369 offs = t_dleft;
20370 break;
20371 case 0b1010:
20372 offs = t_dright;
20373 break;
20374 case 0b1110:
20375 offs = t_notup;
20376 break;
20377 case 0b1101:
20378 offs = t_notdown;
20379 break;
20380 case 0b1011:
20381 offs = t_notleft;
20382 break;
20383 case 0b0111:
20384 offs = t_notright;
20385 break;
20386 case 0b1111:
20387 offs = t_all;
20388 break;
20389 }
20390 if(id > 0) //tile
20391 {
20392 //Draw 'tile' at 'pos'
20393 overtile16(lightbeam_bmp, tile+offs, COMBOX(pos), COMBOY(pos), cs, 0);
20394 }
20395 else //colors
20396 {
20397 masked_blit(cbmp, lightbeam_bmp, offs*16, 0, COMBOX(pos), COMBOY(pos), 16, 16);
20398 }
20399 }
20400 //
20401 if(cbmp) destroy_bitmap(cbmp);
20402 delete[] it->second;
20403 it = maps.erase(it);
20404 }
20405 //Check triggers
20406 3394919 bool hastrigs = false, istrigged = true;
20407
1/2
✓ Branch 0 taken 3394919 times.
✗ Branch 1 not taken.
3394919 bool alltrig = getmapflag(mLIGHTBEAM);
20408
2/2
✓ Branch 0 taken 23764433 times.
✓ Branch 1 taken 3394919 times.
27159352 for(size_t layer = 0; layer < 7; ++layer)
20409 {
20410 23764433 mapscr* curlayer = FFCore.tempScreens[layer];
20411
2/2
✓ Branch 0 taken 4182540208 times.
✓ Branch 1 taken 23764433 times.
4206304641 for(size_t pos = 0; pos < 176; ++pos)
20412 {
20413 4182540208 newcombo const* cmb = &combobuf[curlayer->data[pos]];
20414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4182540208 times.
4182540208 if(cmb->type == cLIGHTTARGET)
20415 {
20416 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
20417 hastrigs = true;
20418 bool trigged = (istrig[pos]&trigflag);
20419 if(cmb->usrflags&cflag2) //Invert
20420 trigged = !trigged;
20421 if(cmb->usrflags&cflag1) //Solved Version
20422 {
20423 if(!(alltrig || trigged)) //Revert
20424 {
20425 curlayer->data[pos] -= 1;
20426 istrigged = false;
20427 }
20428 }
20429 else //Unsolved version
20430 {
20431 if(alltrig || trigged) //Light
20432 curlayer->data[pos] += 1;
20433 else istrigged = false;
20434 }
20435 }
20436
1/2
✓ Branch 0 taken 4182540208 times.
✗ Branch 1 not taken.
4182540208 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
20437 {
20438 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
20439 bool trigged = (istrig[pos]&trigflag);
20440 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
20441 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
20442 {
20443 do_trigger_combo(layer, pos);
20444 }
20445 }
20446 4182540208 }
20447 23764433 }
20448
1/2
✓ Branch 0 taken 3394919 times.
✗ Branch 1 not taken.
3394919 word c = tmpscr->numFFC();
20449
2/2
✓ Branch 0 taken 3394919 times.
✓ Branch 1 taken 104822807 times.
108217726 for(word i=0; i<c; i++)
20450 {
20451 104822807 ffcdata& ffc = tmpscr->ffcs[i];
20452
1/2
✓ Branch 0 taken 104822807 times.
✗ Branch 1 not taken.
104822807 newcombo const* cmb = &combobuf[ffc.getData()];
20453
7/14
✓ Branch 0 taken 104822807 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104822807 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 104822807 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 104822807 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 104822807 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 104822807 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 104822807 times.
✗ Branch 13 not taken.
104822807 size_t pos = COMBOPOS(ffc.x+8, ffc.y+8);
20454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104822807 times.
104822807 if(cmb->type == cLIGHTTARGET)
20455 {
20456 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
20457 hastrigs = true;
20458 bool trigged = (istrig[pos]&trigflag);
20459 if(cmb->usrflags&cflag2) //Invert
20460 trigged = !trigged;
20461 if(cmb->usrflags&cflag1) //Solved Version
20462 {
20463 if(!(alltrig || trigged)) //Revert
20464 {
20465 ffc.incData(-1);
20466 istrigged = false;
20467 }
20468 }
20469 else //Unsolved version
20470 {
20471 if(alltrig || trigged) //Light
20472 ffc.incData(1);
20473 else istrigged = false;
20474 }
20475 }
20476
1/2
✓ Branch 0 taken 104822807 times.
✗ Branch 1 not taken.
104822807 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
20477 {
20478 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
20479 bool trigged = (istrig[pos]&trigflag);
20480 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
20481 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
20482 {
20483 do_trigger_combo_ffc(i);
20484 }
20485 }
20486 104822807 }
20487
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3394919 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3394919 if(hastrigs && istrigged && !alltrig)
20488 {
20489 hidden_entrance(0,true,false,-7);
20490 sfx(tmpscr->secretsfx);
20491 if(!(tmpscr->flags5&fTEMPSECRETS))
20492 {
20493 setmapflag(mSECRET);
20494 setmapflag(mLIGHTBEAM);
20495 }
20496 }
20497 3394919 }
20498
20499 3391281 void HeroClass::checktouchblk()
20500 {
20501
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 3377875 times.
3391281 if(toogam) return;
20502
20503
2/2
✓ Branch 0 taken 155464 times.
✓ Branch 1 taken 3222411 times.
3377875 if(!pushing)
20504 3222411 return;
20505
20506 155464 int32_t tdir = dir; //Bad hack #2. _L_, your welcome to fix this properly. ;)
20507
20508
4/4
✓ Branch 0 taken 155284 times.
✓ Branch 1 taken 180 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 155188 times.
155464 if(charging > 0 || spins > 0) //if not I probably will at some point...
20509 {
20510
3/4
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
276 if(Up()&&Left())tdir = (charging%2)*2;
20511
3/4
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
276 else if(Up()&&Right())tdir = (charging%2)*3;
20512
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
276 else if(Down()&&Left())tdir = 1+(charging%2)*1;
20513
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
276 else if(Down()&&Right())tdir = 1+(charging%2)*2;
20514 else
20515 {
20516
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 6 times.
276 if(Up())tdir=0;
20517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(Down())tdir=1;
20518
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(Left())tdir=2;
20519 else if(Right())tdir=3;
20520 }
20521 276 }
20522
20523 155464 int32_t tx=0,ty=-1;
20524
20525
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 41425 times.
✓ Branch 2 taken 37999 times.
✓ Branch 3 taken 35466 times.
✓ Branch 4 taken 40574 times.
155464 switch(tdir)
20526 {
20527 case up:
20528
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 41385 times.
41425 if(touchcombo(x,y+(bigHitbox?0:7)))
20529 {
20530 40 tx=x;
20531 40 ty=y+(bigHitbox?0:7);
20532 40 }
20533
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 41364 times.
41385 else if(touchcombo(x+8,y+(bigHitbox?0:7)))
20534 {
20535 21 tx=x+8;
20536 21 ty=y+(bigHitbox?0:7);
20537 21 }
20538
20539 41425 break;
20540
20541 case down:
20542
2/2
✓ Branch 0 taken 1253 times.
✓ Branch 1 taken 36746 times.
37999 if(touchcombo(x,y+16))
20543 {
20544 1253 tx=x;
20545 1253 ty=y+16;
20546 1253 }
20547
2/2
✓ Branch 0 taken 237 times.
✓ Branch 1 taken 36509 times.
36746 else if(touchcombo(x+8,y+16))
20548 {
20549 237 tx=x+8;
20550 237 ty=y+16;
20551 237 }
20552
20553 37999 break;
20554
20555 case left:
20556
2/2
✓ Branch 0 taken 34905 times.
✓ Branch 1 taken 561 times.
35466 if(touchcombo(x-1,y+15))
20557 {
20558 561 tx=x-1;
20559 561 ty=y+15;
20560 561 }
20561
20562 35466 break;
20563
20564 case right:
20565
2/2
✓ Branch 0 taken 39585 times.
✓ Branch 1 taken 989 times.
40574 if(touchcombo(x+16,y+15))
20566 {
20567 989 tx=x+16;
20568 989 ty=y+15;
20569 989 }
20570
20571 40574 break;
20572 }
20573
20574
2/2
✓ Branch 0 taken 152363 times.
✓ Branch 1 taken 3101 times.
155464 if(ty>=0)
20575 {
20576 3101 ty&=0xF0;
20577 3101 tx&=0xF0;
20578 3101 int32_t di = ty+(tx>>4);
20579
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3101 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3101 if((getAction() != hopping || isSideViewHero()))
20580 {
20581 3101 trigger_armos_grave(0, di, dir);
20582 3101 }
20583 3101 }
20584 3391281 }
20585
20586 int32_t HeroClass::nextcombo(int32_t cx, int32_t cy, int32_t cdir)
20587 {
20588 switch(cdir)
20589 {
20590 case up:
20591 cy-=16;
20592 break;
20593
20594 case down:
20595 cy+=16;
20596 break;
20597
20598 case left:
20599 cx-=16;
20600 break;
20601
20602 case right:
20603 cx+=16;
20604 break;
20605 }
20606
20607 // off the screen
20608 if(cx<0 || cy<0 || cx>255 || cy>175)
20609 {
20610 int32_t ns = nextscr(cdir);
20611
20612 if(ns==0xFFFF) return 0;
20613
20614 // want actual screen index, not game->maps[] index
20615 ns = (ns&127) + (ns>>7)*MAPSCRS;
20616
20617 switch(cdir)
20618 {
20619 case up:
20620 cy=160;
20621 break;
20622
20623 case down:
20624 cy=0;
20625 break;
20626
20627 case left:
20628 cx=240;
20629 break;
20630
20631 case right:
20632 cx=0;
20633 break;
20634 }
20635
20636 // from MAPCOMBO()
20637 int32_t cmb = (cy&0xF0)+(cx>>4);
20638
20639 if(cmb>175)
20640 return 0;
20641
20642 return TheMaps[ns].data[cmb]; // entire combo code
20643 }
20644
20645 return MAPCOMBO(cx,cy);
20646 }
20647
20648 2361 int32_t HeroClass::nextflag(int32_t cx, int32_t cy, int32_t cdir, bool comboflag)
20649 {
20650
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 560 times.
✓ Branch 2 taken 467 times.
✓ Branch 3 taken 658 times.
✓ Branch 4 taken 676 times.
2361 switch(cdir)
20651 {
20652 case up:
20653 560 cy-=16;
20654 560 break;
20655
20656 case down:
20657 467 cy+=16;
20658 467 break;
20659
20660 case left:
20661 658 cx-=16;
20662 658 break;
20663
20664 case right:
20665 676 cx+=16;
20666 676 break;
20667 }
20668
20669 // off the screen
20670
8/8
✓ Branch 0 taken 2339 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 2308 times.
✓ Branch 3 taken 31 times.
✓ Branch 4 taken 2283 times.
✓ Branch 5 taken 25 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 2267 times.
2361 if(cx<0 || cy<0 || cx>255 || cy>175)
20671 {
20672 94 int32_t ns = nextscr(cdir);
20673
20674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(ns==0xFFFF) return 0;
20675
20676 // want actual screen index, not game->maps[] index
20677 94 ns = (ns&127) + (ns>>7)*MAPSCRS;
20678
20679
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 25 times.
94 switch(cdir)
20680 {
20681 case up:
20682 31 cy=160;
20683 31 break;
20684
20685 case down:
20686 16 cy=0;
20687 16 break;
20688
20689 case left:
20690 22 cx=240;
20691 22 break;
20692
20693 case right:
20694 25 cx=0;
20695 25 break;
20696 }
20697
20698 // from MAPCOMBO()
20699 94 int32_t cmb = (cy&0xF0)+(cx>>4);
20700
20701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(cmb>175)
20702 return 0;
20703
20704
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 87 times.
94 if(!comboflag)
20705 {
20706 87 return TheMaps[ns].sflag[cmb]; // flag
20707 }
20708 else
20709 {
20710 7 return combobuf[TheMaps[ns].data[cmb]].flag; // flag
20711 }
20712 }
20713
20714
2/2
✓ Branch 0 taken 541 times.
✓ Branch 1 taken 1726 times.
2267 if(comboflag)
20715 {
20716 541 return MAPCOMBOFLAG(cx,cy);
20717 }
20718
20719 1726 return MAPFLAG(cx,cy);
20720 2361 }
20721
20722 bool did_secret;
20723
20724 3391281 void HeroClass::checkspecial()
20725 {
20726 3391281 checktouchblk();
20727
20728 3391281 bool hasmainguy = hasMainGuy(); // calculate it once
20729
20730
4/4
✓ Branch 0 taken 3351719 times.
✓ Branch 1 taken 39562 times.
✓ Branch 2 taken 2451295 times.
✓ Branch 3 taken 900424 times.
3391281 if(!(loaded_enemies && !hasmainguy))
20731 2490857 did_secret=false;
20732 else
20733 {
20734 // after beating enemies
20735
20736 // item
20737
2/2
✓ Branch 0 taken 900125 times.
✓ Branch 1 taken 299 times.
900424 if(hasitem&(4|2|1))
20738 {
20739 299 int32_t Item=tmpscr->item;
20740
20741 //if(getmapflag())
20742 // Item=0;
20743
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
299 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
20744 {
20745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if(hasitem==1)
20746 299 sfx(WAV_CLEARED);
20747
20748
2/4
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 299 times.
✗ Branch 3 not taken.
598 items.add(new item((zfix)tmpscr->itemx,
20749
6/12
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 273 times.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 26 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 299 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 299 times.
✗ Branch 11 not taken.
299 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
20750
6/10
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 273 times.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 26 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 273 times.
✗ Branch 9 not taken.
299 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
20751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
20752 299 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
20753 299 }
20754
20755 299 hasitem &= ~ (4|2|1);
20756 299 }
20757
20758 // generic 'Enemies->' trigger
20759
2/2
✓ Branch 0 taken 6302968 times.
✓ Branch 1 taken 900424 times.
7203392 for(auto lyr = 0; lyr < 7; ++lyr)
20760 {
20761
2/2
✓ Branch 0 taken 1109322368 times.
✓ Branch 1 taken 6302968 times.
1115625336 for(auto pos = 0; pos < 176; ++pos)
20762 {
20763 1109322368 newcombo const& cmb = combobuf[FFCore.tempScreens[lyr]->data[pos]];
20764
1/2
✓ Branch 0 taken 1109322368 times.
✗ Branch 1 not taken.
1109322368 if(cmb.triggerflags[2] & combotriggerKILLENEMIES)
20765 {
20766 do_trigger_combo(lyr,pos);
20767 }
20768 1109322368 }
20769 6302968 }
20770 900424 word c = tmpscr->numFFC();
20771
2/2
✓ Branch 0 taken 26165364 times.
✓ Branch 1 taken 900424 times.
27065788 for(word i=0; i<c; i++)
20772 {
20773 26165364 ffcdata& ffc = tmpscr->ffcs[i];
20774 26165364 newcombo const& cmb = combobuf[ffc.getData()];
20775
1/2
✓ Branch 0 taken 26165364 times.
✗ Branch 1 not taken.
26165364 if(cmb.triggerflags[2] & combotriggerKILLENEMIES)
20776 {
20777 do_trigger_combo_ffc(i);
20778 }
20779 26165364 }
20780
1/2
✓ Branch 0 taken 900424 times.
✗ Branch 1 not taken.
900424 if(tmpscr->flags9 & fENEMY_WAVES)
20781 {
20782 hasmainguy = hasMainGuy(); //possibly un-beat the enemies (another 'wave'?)
20783 }
20784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 900424 times.
900424 if(!hasmainguy)
20785 {
20786 // if room has traps, guys don't come back
20787
2/2
✓ Branch 0 taken 461017088 times.
✓ Branch 1 taken 900424 times.
461917512 for(int32_t i=0; i<eMAXGUYS; i++)
20788 {
20789
4/4
✓ Branch 0 taken 13449758 times.
✓ Branch 1 taken 447567330 times.
✓ Branch 2 taken 1744246 times.
✓ Branch 3 taken 11705512 times.
461017088 if(guysbuf[i].family==eeTRAP&&guysbuf[i].misc2)
20790
4/4
✓ Branch 0 taken 5515 times.
✓ Branch 1 taken 1738731 times.
✓ Branch 2 taken 5513 times.
✓ Branch 3 taken 2 times.
1744248 if(guys.idCount(i) && !getmapflag(mTMPNORET))
20791 2 setmapflag(mTMPNORET);
20792 461017088 }
20793 // clear enemies and open secret
20794
4/4
✓ Branch 0 taken 790416 times.
✓ Branch 1 taken 110008 times.
✓ Branch 2 taken 790005 times.
✓ Branch 3 taken 411 times.
900424 if(!did_secret && (tmpscr->flags2&fCLEARSECRET))
20795 {
20796 411 bool only16_31 = get_bit(quest_rules,qr_ENEMIES_SECRET_ONLY_16_31)?true:false;
20797 411 hidden_entrance(0,true,only16_31,-2);
20798
20799
4/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 394 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 12 times.
411 if(tmpscr->flags4&fENEMYSCRTPERM && canPermSecret())
20800 {
20801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
20802 12 }
20803
20804 411 sfx(tmpscr->secretsfx);
20805 411 did_secret=true;
20806 411 }
20807 900424 }
20808 }
20809
20810 // doors
20811
2/2
✓ Branch 0 taken 2381011 times.
✓ Branch 1 taken 11792545 times.
14173556 for(int32_t i=0; i<4; i++)
20812
2/2
✓ Branch 0 taken 10782275 times.
✓ Branch 1 taken 1010270 times.
11792545 if(tmpscr->door[i]==dSHUTTER)
20813 {
20814
4/4
✓ Branch 0 taken 994446 times.
✓ Branch 1 taken 15824 times.
✓ Branch 2 taken 567 times.
✓ Branch 3 taken 993879 times.
1010270 if(opendoors==0 && loaded_enemies)
20815 {
20816
4/4
✓ Branch 0 taken 871594 times.
✓ Branch 1 taken 122285 times.
✓ Branch 2 taken 870599 times.
✓ Branch 3 taken 995 times.
993879 if(!(tmpscr->flags&fSHUTTERS) && !hasmainguy)
20817 995 opendoors=12;
20818 993879 }
20819
2/2
✓ Branch 0 taken 13095 times.
✓ Branch 1 taken 3296 times.
16391 else if(opendoors<0)
20820 3296 ++opendoors;
20821
2/2
✓ Branch 0 taken 12026 times.
✓ Branch 1 taken 1069 times.
13095 else if((--opendoors)==0)
20822 1069 openshutters();
20823
20824 1010270 break;
20825 }
20826
20827 // set boss flag when boss is gone
20828
6/6
✓ Branch 0 taken 3351719 times.
✓ Branch 1 taken 39562 times.
✓ Branch 2 taken 38854 times.
✓ Branch 3 taken 3312865 times.
✓ Branch 4 taken 28516 times.
✓ Branch 5 taken 10338 times.
3391281 if(loaded_enemies && tmpscr->enemyflags&efBOSS && !hasmainguy)
20829 {
20830 10338 game->lvlitems[dlevel]|=liBOSS;
20831 10338 stop_sfx(tmpscr->bosssfx);
20832 10338 }
20833
20834
2/2
✓ Branch 0 taken 3378765 times.
✓ Branch 1 taken 12516 times.
3391281 if(getmapflag(mCHEST)) // if special stuff done before
20835 {
20836 12516 remove_chests((currscr>=128)?1:0);
20837 12516 }
20838
20839
1/2
✓ Branch 0 taken 3391281 times.
✗ Branch 1 not taken.
3391281 if(getmapflag(mLOCKEDCHEST)) // if special stuff done before
20840 {
20841 remove_lockedchests((currscr>=128)?1:0);
20842 }
20843
20844
1/2
✓ Branch 0 taken 3391281 times.
✗ Branch 1 not taken.
3391281 if(getmapflag(mBOSSCHEST)) // if special stuff done before
20845 {
20846 remove_bosschests((currscr>=128)?1:0);
20847 }
20848
20849 3391281 clear_xstatecombos((currscr>=128)?1:0);
20850
20851
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3391281 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3391281 if((hasitem&8) && triggered_screen_secrets)
20852 {
20853 int32_t Item=tmpscr->item;
20854
20855 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
20856 {
20857 items.add(new item((zfix)tmpscr->itemx,
20858 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
20859 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
20860 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
20861 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
20862 }
20863
20864 hasitem &= ~8;
20865 }
20866 3391281 }
20867
20868 //Gets the 4 comboposes indicated by the coordinates, replacing duplicates with '-1'
20869 2078522 void getPoses(int32_t* poses, int32_t x1, int32_t y1, int32_t x2, int32_t y2)
20870 {
20871 int32_t tmp;
20872 2078522 poses[0] = COMBOPOS(x1,y1);
20873
20874 2078522 tmp = COMBOPOS(x1,y2);
20875
2/2
✓ Branch 0 taken 1575630 times.
✓ Branch 1 taken 502892 times.
2078522 if(tmp == poses[0])
20876 1575630 poses[1] = -1;
20877 502892 else poses[1] = tmp;
20878
20879 2078522 tmp = COMBOPOS(x2,y1);
20880
3/4
✓ Branch 0 taken 886142 times.
✓ Branch 1 taken 1192380 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 886142 times.
2078522 if(tmp == poses[0] || tmp == poses[1])
20881 1192380 poses[2] = -1;
20882 886142 else poses[2] = tmp;
20883
20884 2078522 tmp = COMBOPOS(x2,y2);
20885
6/6
✓ Branch 0 taken 1176480 times.
✓ Branch 1 taken 902042 times.
✓ Branch 2 taken 886142 times.
✓ Branch 3 taken 290338 times.
✓ Branch 4 taken 673588 times.
✓ Branch 5 taken 212554 times.
2078522 if(tmp == poses[0] || tmp == poses[1] || tmp == poses[2])
20886 1865968 poses[3] = -1;
20887 212554 else poses[3] = tmp;
20888 2078522 }
20889
20890 3390685 void HeroClass::checkspecial2(int32_t *ls)
20891 {
20892
4/6
✓ Branch 0 taken 3119385 times.
✓ Branch 1 taken 271300 times.
✓ Branch 2 taken 3119385 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3119385 times.
3390685 if(get_bit(quest_rules,qr_OLDSTYLEWARP) && !(diagonalMovement||NO_GRIDLOCK))
20893 {
20894
2/2
✓ Branch 0 taken 924630 times.
✓ Branch 1 taken 2194755 times.
3119385 if(y.getInt()&7)
20895 924630 return;
20896
20897
2/2
✓ Branch 0 taken 1273403 times.
✓ Branch 1 taken 921352 times.
2194755 if(x.getInt()&7)
20898 1273403 return;
20899 921352 }
20900
20901
2/2
✓ Branch 0 taken 4512 times.
✓ Branch 1 taken 1188140 times.
1192652 if(toogam) return;
20902
20903 1188140 bool didstrig = false;
20904
20905
2/2
✓ Branch 0 taken 2375945 times.
✓ Branch 1 taken 1188137 times.
3564082 for(int32_t i=bigHitbox?0:8; i<16; i+=bigHitbox?15:7)
20906 {
20907
4/4
✓ Branch 0 taken 4751890 times.
✓ Branch 1 taken 2375942 times.
✓ Branch 2 taken 9503777 times.
✓ Branch 3 taken 4751887 times.
16631606 for(int32_t j=0; j<16; j+=15) for(int32_t k=0; k<2; k++)
20908 {
20909
2/2
✓ Branch 0 taken 4751887 times.
✓ Branch 1 taken 4751890 times.
9503777 newcombo const& cmb = combobuf[k>0 ? MAPFFCOMBO(x+j,y+i) : MAPCOMBO(x+j,y+i)];
20910 9503777 int32_t stype = cmb.type;
20911 9503777 int32_t warpsound = cmb.attribytes[0];
20912
1/2
✓ Branch 0 taken 9503777 times.
✗ Branch 1 not taken.
9503777 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
20913 stype = cNONE;
20914
2/2
✓ Branch 0 taken 9503774 times.
✓ Branch 1 taken 3 times.
9503777 if(stype==cSWARPA)
20915 {
20916
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(tmpscr->flags5&fDIRECTSWARP)
20917 {
20918 didpit=true;
20919 pitx=x;
20920 pity=y;
20921 }
20922
20923 3 sdir=dir;
20924 3 dowarp(0,0,warpsound);
20925 3 return;
20926 }
20927
20928
1/2
✓ Branch 0 taken 9503774 times.
✗ Branch 1 not taken.
9503774 if(stype==cSWARPB)
20929 {
20930 if(tmpscr->flags5&fDIRECTSWARP)
20931 {
20932 didpit=true;
20933 pitx=x;
20934 pity=y;
20935 }
20936
20937 sdir=dir;
20938 dowarp(0,1,warpsound);
20939 return;
20940 }
20941
20942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9503774 times.
9503774 if(stype==cSWARPC)
20943 {
20944 if(tmpscr->flags5&fDIRECTSWARP)
20945 {
20946 didpit=true;
20947 pitx=x;
20948 pity=y;
20949 }
20950
20951 sdir=dir;
20952 dowarp(0,2,warpsound);
20953 return;
20954 }
20955
20956
1/2
✓ Branch 0 taken 9503774 times.
✗ Branch 1 not taken.
9503774 if(stype==cSWARPD)
20957 {
20958 if(tmpscr->flags5&fDIRECTSWARP)
20959 {
20960 didpit=true;
20961 pitx=x;
20962 pity=y;
20963 }
20964
20965 sdir=dir;
20966 dowarp(0,3,warpsound);
20967 return;
20968 }
20969
20970
1/2
✓ Branch 0 taken 9503774 times.
✗ Branch 1 not taken.
9503774 if(stype==cSWARPR)
20971 {
20972 if(tmpscr->flags5&fDIRECTSWARP)
20973 {
20974 didpit=true;
20975 pitx=x;
20976 pity=y;
20977 }
20978
20979 sdir=dir;
20980 dowarp(0,(zc_oldrand()%4),warpsound);
20981 return;
20982 }
20983
20984 9503774 int32_t pos = COMBOPOS(x+j, y+i);
20985
4/4
✓ Branch 0 taken 9501618 times.
✓ Branch 1 taken 2156 times.
✓ Branch 2 taken 9503064 times.
✓ Branch 3 taken 710 times.
9503774 if((stype==cSTRIGNOFLAG || stype==cSTRIGFLAG) && stepsecret!=pos)
20986 {
20987 // zprint("Step Secs\n");
20988
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
710 if(stype==cSTRIGFLAG && canPermSecret())
20989 {
20990 if(!didstrig)
20991 {
20992 stepsecret = pos;
20993
20994 if(!(tmpscr->flags5&fTEMPSECRETS))
20995 {
20996 setmapflag(mSECRET);
20997 }
20998 //int32_t thesfx = combobuf[MAPCOMBO(x+j,y+i)].attribytes[0];
20999 //zprint("Step Secrets SFX: %d\n", thesfx);
21000 sfx(warpsound,pan((int32_t)x));
21001 hidden_entrance(0,true,false);
21002 didstrig = true;
21003 }
21004 }
21005 else
21006 {
21007
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 345 times.
710 if(!didstrig)
21008 {
21009 345 stepsecret = pos;
21010 345 bool only16_31 = get_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
21011 345 hidden_entrance(0,true,only16_31);
21012 345 didstrig = true;
21013 //play trigger sound
21014 //int32_t thesfx = combobuf[MAPCOMBO(x+j,y+i)].attribytes[0];
21015 //zprint("Step Secrets SFX: %d\n", thesfx);
21016 //sfx(thesfx,pan((int32_t)x));
21017 345 sfx(warpsound,pan((int32_t)x));
21018 345 }
21019 }
21020 710 }
21021 14255661 }
21022 2375942 }
21023
21024 1188137 bool RaftPass = false;//Special case for the raft, where only the raft stuff gets checked and nothing else.
21025
21026 // check if he's standing on a warp he just came out of
21027 // But if the QR is checked, it uses the old logic, cause some quests like Ballad of a Bloodline warp you onto a trigger and this new logic bricks that.
21028
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 1187971 times.
1188137 if (!get_bit(quest_rules,qr_210_WARPRETURN))
21029 {
21030
6/6
✓ Branch 0 taken 1186743 times.
✓ Branch 1 taken 1228 times.
✓ Branch 2 taken 151203 times.
✓ Branch 3 taken 1035540 times.
✓ Branch 4 taken 12469 times.
✓ Branch 5 taken 138734 times.
1187971 if(((int32_t)y>=warpy-8&&(int32_t)y<=warpy+7)&&warpy!=-1)
21031 {
21032
5/6
✓ Branch 0 taken 138124 times.
✓ Branch 1 taken 610 times.
✓ Branch 2 taken 137156 times.
✓ Branch 3 taken 968 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 137156 times.
138734 if(((int32_t)x>=warpx-8&&(int32_t)x<=warpx+7)&&warpx!=-1)
21033 {
21034
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 137151 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
137156 if (get_bit(quest_rules, qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
21035 137156 else return;
21036 }
21037 1578 }
21038 1050815 }
21039 else
21040 {
21041
1/2
✓ Branch 0 taken 166 times.
✗ Branch 1 not taken.
166 if((int(y)&0xF8)==warpy)
21042 {
21043 if(x==warpx)
21044 {
21045 if (get_bit(quest_rules, qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
21046 else return;
21047 }
21048 }
21049 }
21050
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 1050815 times.
1050981 if (!RaftPass) warpy=-1;
21051
21052
6/6
✓ Branch 0 taken 1048843 times.
✓ Branch 1 taken 1806 times.
✓ Branch 2 taken 54695 times.
✓ Branch 3 taken 994148 times.
✓ Branch 4 taken 42060 times.
✓ Branch 5 taken 12635 times.
1050981 if(((int32_t)y<raftwarpy-(get_bit(quest_rules, qr_BETTER_RAFT_2)?12:8)||(int32_t)y>raftwarpy+(get_bit(quest_rules, qr_BETTER_RAFT_2)?3:7))||raftwarpy==-1)
21053 {
21054 1008589 raftwarpy = -1;
21055 1008589 }
21056
6/6
✓ Branch 0 taken 1049406 times.
✓ Branch 1 taken 1243 times.
✓ Branch 2 taken 61538 times.
✓ Branch 3 taken 987868 times.
✓ Branch 4 taken 47141 times.
✓ Branch 5 taken 14397 times.
1050649 if (((int32_t)x<raftwarpx - 8 || (int32_t)x>raftwarpx + 7) || raftwarpx == -1)
21057 {
21058 1003508 raftwarpx = -1;
21059 1003508 }
21060 1050649 int32_t tx=x;
21061 1050649 int32_t ty=y;
21062
21063 1050649 int32_t flag=0;
21064 1050649 int32_t flag2=0;
21065 1050649 int32_t flag3=0;
21066 1050649 int32_t type=0;
21067 1050649 int32_t water=0;
21068 1050649 int32_t index = 0;
21069
21070 1050649 bool setsave=false;
21071 1050649 int32_t warpsfx2 = 0;
21072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1050649 times.
1050649 if (RaftPass) goto RaftingStuff;
21073
21074 //bool gotpit=false;
21075
21076 int32_t x1,x2,y1,y2;
21077 1050649 x1 = tx;
21078 1050649 x2 = tx+15;
21079 1050649 y1 = ty;
21080 1050649 y2 = ty+15;
21081
21082
4/4
✓ Branch 0 taken 791392 times.
✓ Branch 1 taken 259257 times.
✓ Branch 2 taken 166 times.
✓ Branch 3 taken 791558 times.
1050649 if((diagonalMovement||NO_GRIDLOCK))
21083 {
21084 259423 x1 = tx+4;
21085 259423 x2 = tx+11;
21086 259423 y1 = ty+4;
21087 259423 y2 = ty+11;
21088 259423 }
21089
21090 int32_t types[4];
21091 1050981 types[0]=types[1]=types[2]=types[3]=-1;
21092 int32_t cids[4];
21093 int32_t ffcids[4];
21094 1050981 cids[0]=cids[1]=cids[2]=cids[3]=-1;
21095 1050981 ffcids[0]=ffcids[1]=ffcids[2]=ffcids[3]=-1;
21096 //
21097 // First, let's find flag1 (combo flag), flag2 (inherent flag) and flag3 (FFC flag)...
21098 //
21099 1050981 types[0] = MAPFLAG(x1,y1);
21100 1050981 types[1] = MAPFLAG(x1,y2);
21101 1050981 types[2] = MAPFLAG(x2,y1);
21102 1050981 types[3] = MAPFLAG(x2,y2);
21103
21104
21105 //MAPFFCOMBO
21106
21107
21108
6/6
✓ Branch 0 taken 1020843 times.
✓ Branch 1 taken 30138 times.
✓ Branch 2 taken 1017163 times.
✓ Branch 3 taken 3680 times.
✓ Branch 4 taken 4991 times.
✓ Branch 5 taken 1012172 times.
1050981 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21109 1012172 flag = types[0];
21110
21111 // 2.10 compatibility...
21112
8/10
✓ Branch 0 taken 30923 times.
✓ Branch 1 taken 7886 times.
✓ Branch 2 taken 26394 times.
✓ Branch 3 taken 4529 times.
✓ Branch 4 taken 17057 times.
✓ Branch 5 taken 9337 times.
✓ Branch 6 taken 17057 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 17057 times.
38809 else if(y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
21113 9337 flag = types[0];
21114
21115
21116 1050981 types[0] = MAPCOMBOFLAG(x1,y1);
21117 1050981 types[1] = MAPCOMBOFLAG(x1,y2);
21118 1050981 types[2] = MAPCOMBOFLAG(x2,y1);
21119 1050981 types[3] = MAPCOMBOFLAG(x2,y2);
21120
21121
6/6
✓ Branch 0 taken 1049416 times.
✓ Branch 1 taken 1565 times.
✓ Branch 2 taken 1049082 times.
✓ Branch 3 taken 334 times.
✓ Branch 4 taken 374 times.
✓ Branch 5 taken 1048708 times.
1050981 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21122 1048708 flag2 = types[0];
21123
21124 1050981 types[0] = MAPFFCOMBOFLAG(x1,y1);
21125 1050981 types[1] = MAPFFCOMBOFLAG(x1,y2);
21126 1050981 types[2] = MAPFFCOMBOFLAG(x2,y1);
21127 1050981 types[3] = MAPFFCOMBOFLAG(x2,y2);
21128
21129
21130 //
21131
21132
6/6
✓ Branch 0 taken 1050809 times.
✓ Branch 1 taken 172 times.
✓ Branch 2 taken 1050799 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 1050796 times.
1050981 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21133 1050796 flag3 = types[0];
21134
21135 //
21136 // Now, let's check for warp combos...
21137 //
21138
21139 //
21140
21141 1050981 cids[0] = MAPCOMBO(x1,y1);
21142 1050981 cids[1] = MAPCOMBO(x1,y2);
21143 1050981 cids[2] = MAPCOMBO(x2,y1);
21144 1050981 cids[3] = MAPCOMBO(x2,y2);
21145
21146 1050981 types[0] = COMBOTYPE(x1,y1);
21147
21148
2/2
✓ Branch 0 taken 1042482 times.
✓ Branch 1 taken 8499 times.
1050981 if(MAPFFCOMBO(x1,y1))
21149 {
21150 8499 types[0] = FFCOMBOTYPE(x1,y1);
21151 8499 cids[0] = MAPFFCOMBO(x1,y1);
21152 8499 }
21153
21154 1050981 types[1] = COMBOTYPE(x1,y2);
21155
21156
2/2
✓ Branch 0 taken 1046259 times.
✓ Branch 1 taken 4722 times.
1050981 if(MAPFFCOMBO(x1,y2))
21157 {
21158 4722 types[1] = FFCOMBOTYPE(x1,y2);
21159 4722 cids[1] = MAPFFCOMBO(x1,y2);
21160 4722 }
21161
21162 1050981 types[2] = COMBOTYPE(x2,y1);
21163
21164
2/2
✓ Branch 0 taken 1042959 times.
✓ Branch 1 taken 8022 times.
1050981 if(MAPFFCOMBO(x2,y1))
21165 {
21166 8022 types[2] = FFCOMBOTYPE(x2,y1);
21167 8022 cids[2] = MAPFFCOMBO(x2,y1);
21168 8022 }
21169 1050981 types[3] = COMBOTYPE(x2,y2);
21170
21171
2/2
✓ Branch 0 taken 1046714 times.
✓ Branch 1 taken 4267 times.
1050981 if(MAPFFCOMBO(x2,y2))
21172 {
21173 4267 types[3] = FFCOMBOTYPE(x2,y2);
21174 4267 cids[3] = MAPFFCOMBO(x2,y2);
21175 4267 }
21176 // Change B, C and D warps into A, for the comparison below...
21177
2/2
✓ Branch 0 taken 4203260 times.
✓ Branch 1 taken 1050981 times.
5254241 for(int32_t i=0; i<4; i++)
21178 {
21179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4203260 times.
4203260 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
21180 {
21181 types[i] = cNONE;
21182 continue;
21183 }
21184
2/2
✓ Branch 0 taken 1598 times.
✓ Branch 1 taken 4201662 times.
4203260 if(types[i]==cCAVE)
21185 {
21186 1598 index=0;
21187 1598 warpsfx2 = combobuf[cids[i]].attribytes[0];
21188 1598 }
21189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4201662 times.
4201662 else if(types[i]==cCAVEB)
21190 {
21191 types[i]=cCAVE;
21192 index=1;
21193 warpsfx2 = combobuf[cids[i]].attribytes[0];
21194 }
21195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4201662 times.
4201662 else if(types[i]==cCAVEC)
21196 {
21197 types[i]=cCAVE;
21198 index=2;
21199 warpsfx2 = combobuf[cids[i]].attribytes[0];
21200 }
21201
1/2
✓ Branch 0 taken 4201662 times.
✗ Branch 1 not taken.
4201662 else if(types[i]==cCAVED)
21202 {
21203 types[i]=cCAVE;
21204 index=3;
21205 warpsfx2 = combobuf[cids[i]].attribytes[0];
21206 }
21207
21208
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 4203136 times.
4203260 if(types[i]==cPIT)
21209 {
21210 124 index=0;
21211 124 warpsfx2 = combobuf[cids[i]].attribytes[0];
21212 124 }
21213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4203136 times.
4203136 else if(types[i]==cPITB)
21214 {
21215 types[i]=cPIT;
21216 warpsfx2 = combobuf[cids[i]].attribytes[0];
21217 index=1;
21218 }
21219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4203136 times.
4203136 else if(types[i]==cPITC)
21220 {
21221 types[i]=cPIT;
21222 warpsfx2 = combobuf[cids[i]].attribytes[0];
21223 index=2;
21224 }
21225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4203136 times.
4203136 else if(types[i]==cPITD)
21226 {
21227 types[i]=cPIT;
21228 warpsfx2 = combobuf[cids[i]].attribytes[0];
21229 index=3;
21230 }
21231
1/2
✓ Branch 0 taken 4203136 times.
✗ Branch 1 not taken.
4203136 else if(types[i]==cPITR)
21232 {
21233 types[i]=cPIT;
21234 warpsfx2 = combobuf[cids[i]].attribytes[0];
21235 index=zc_oldrand()%4;
21236 }
21237
21238
2/2
✓ Branch 0 taken 6596 times.
✓ Branch 1 taken 4196664 times.
4203260 if(types[i]==cSTAIR)
21239 {
21240 6596 index=0;
21241 6596 warpsfx2 = combobuf[cids[i]].attribytes[0];
21242 6596 }
21243
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 4196564 times.
4196664 else if(types[i]==cSTAIRB)
21244 {
21245 100 types[i]=cSTAIR;
21246 100 warpsfx2 = combobuf[cids[i]].attribytes[0];
21247 100 index=1;
21248 100 }
21249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4196564 times.
4196564 else if(types[i]==cSTAIRC)
21250 {
21251 types[i]=cSTAIR;
21252 warpsfx2 = combobuf[cids[i]].attribytes[0];
21253 index=2;
21254 }
21255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4196564 times.
4196564 else if(types[i]==cSTAIRD)
21256 {
21257 types[i]=cSTAIR;
21258 warpsfx2 = combobuf[cids[i]].attribytes[0];
21259 index=3;
21260 }
21261
1/2
✓ Branch 0 taken 4196564 times.
✗ Branch 1 not taken.
4196564 else if(types[i]==cSTAIRR)
21262 {
21263 types[i]=cSTAIR;
21264 index=zc_oldrand()%4;
21265 warpsfx2 = combobuf[cids[i]].attribytes[0];
21266 }
21267
21268
2/2
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 4202909 times.
4203260 if(types[i]==cCAVE2)
21269 {
21270 351 index=0;
21271 351 warpsfx2 = combobuf[cids[i]].attribytes[0];
21272 351 }
21273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4202909 times.
4202909 else if(types[i]==cCAVE2B)
21274 {
21275 types[i]=cCAVE2;
21276 index=1;
21277 warpsfx2 = combobuf[cids[i]].attribytes[0];
21278 }
21279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4202909 times.
4202909 else if(types[i]==cCAVE2C)
21280 {
21281 types[i]=cCAVE2;
21282 warpsfx2 = combobuf[cids[i]].attribytes[0];
21283 index=2;
21284 }
21285
1/2
✓ Branch 0 taken 4202909 times.
✗ Branch 1 not taken.
4202909 else if(types[i]==cCAVE2D)
21286 {
21287 types[i]=cCAVE2;
21288 warpsfx2 = combobuf[cids[i]].attribytes[0];
21289 index=3;
21290 }
21291
21292
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 4203219 times.
4203260 if(types[i]==cSWIMWARP)
21293 {
21294 41 index=0;
21295 41 warpsfx2 = combobuf[cids[i]].attribytes[0];
21296 41 }
21297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4203219 times.
4203219 else if(types[i]==cSWIMWARPB)
21298 {
21299 types[i]=cSWIMWARP;
21300 warpsfx2 = combobuf[cids[i]].attribytes[0];
21301 index=1;
21302 }
21303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4203219 times.
4203219 else if(types[i]==cSWIMWARPC)
21304 {
21305 types[i]=cSWIMWARP;
21306 warpsfx2 = combobuf[cids[i]].attribytes[0];
21307 index=2;
21308 }
21309
1/2
✓ Branch 0 taken 4203219 times.
✗ Branch 1 not taken.
4203219 else if(types[i]==cSWIMWARPD)
21310 {
21311 types[i]=cSWIMWARP;
21312 warpsfx2 = combobuf[cids[i]].attribytes[0];
21313 index=3;
21314 }
21315
21316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4203260 times.
4203260 if(types[i]==cDIVEWARP)
21317 {
21318 index=0;
21319 warpsfx2 = combobuf[cids[i]].attribytes[0];
21320 }
21321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4203260 times.
4203260 else if(types[i]==cDIVEWARPB)
21322 {
21323 types[i]=cDIVEWARP;
21324 warpsfx2 = combobuf[cids[i]].attribytes[0];
21325 index=1;
21326 }
21327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4203260 times.
4203260 else if(types[i]==cDIVEWARPC)
21328 {
21329 types[i]=cDIVEWARP;
21330 warpsfx2 = combobuf[cids[i]].attribytes[0];
21331 index=2;
21332 }
21333
1/2
✓ Branch 0 taken 4203260 times.
✗ Branch 1 not taken.
4203260 else if(types[i]==cDIVEWARPD)
21334 {
21335 types[i]=cDIVEWARP;
21336 warpsfx2 = combobuf[cids[i]].attribytes[0];
21337 index=3;
21338 }
21339
21340
2/2
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 4202570 times.
4203260 if(types[i]==cSTEP) warpsfx2 = combobuf[cids[i]].attribytes[0];
21341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4202570 times.
4202570 else if(types[i]==cSTEPSAME) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0];}
21342
2/2
✓ Branch 0 taken 4202554 times.
✓ Branch 1 taken 16 times.
4202570 else if(types[i]==cSTEPALL) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0]; }
21343 4203260 }
21344
21345 // Special case for step combos; otherwise, they act oddly in some cases
21346
8/8
✓ Branch 0 taken 962636 times.
✓ Branch 1 taken 88345 times.
✓ Branch 2 taken 951189 times.
✓ Branch 3 taken 11447 times.
✓ Branch 4 taken 83 times.
✓ Branch 5 taken 99709 times.
✓ Branch 6 taken 12060 times.
✓ Branch 7 taken 11977 times.
1050981 if((types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])||(types[1]==cSTEP&&types[3]==cSTEP))
21347 {
21348
7/8
✓ Branch 0 taken 928873 times.
✓ Branch 1 taken 10256 times.
✓ Branch 2 taken 928873 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 174 times.
✓ Branch 5 taken 928699 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 171 times.
963249 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
21349 928870 type = types[1];
21350 939129 }
21351
21352 //Generic Step
21353
7/8
✓ Branch 0 taken 1039264 times.
✓ Branch 1 taken 11551 times.
✓ Branch 2 taken 1039264 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 174 times.
✓ Branch 5 taken 1039090 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 171 times.
1050815 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
21354 {
21355 int32_t poses[4];
21356 int32_t sensPoses[4];
21357 1039261 int32_t xPoses[4] = {tx + 4, tx + 11, tx, tx + 15};
21358 1039261 int32_t yPoses[4] = {ty + 4, ty + 11, ty+(bigHitbox?0:8), ty + 15};
21359
3/4
✓ Branch 0 taken 780441 times.
✓ Branch 1 taken 258820 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 780441 times.
1039261 if(diagonalMovement||NO_GRIDLOCK)
21360 258820 getPoses(poses, tx+4, ty+4, tx+11, ty+11);
21361 780441 else getPoses(poses, tx, ty, tx+15, ty+15);
21362 1039261 getPoses(sensPoses, tx, ty+(bigHitbox?0:8), tx+15, ty+15);
21363 1039261 bool hasStep[4] = {false};
21364
2/2
✓ Branch 0 taken 4157044 times.
✓ Branch 1 taken 1039261 times.
5196305 for(auto p = 0; p < 4; ++p)
21365 {
21366
2/2
✓ Branch 0 taken 4156338 times.
✓ Branch 1 taken 29095072 times.
33251410 for(auto lyr = 0; lyr < 7; ++lyr)
21367 {
21368
2/2
✓ Branch 0 taken 14122558 times.
✓ Branch 1 taken 14972514 times.
29095072 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
21369
4/4
✓ Branch 0 taken 14122558 times.
✓ Branch 1 taken 14972514 times.
✓ Branch 2 taken 706 times.
✓ Branch 3 taken 29094366 times.
29095072 if((cmb && (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS)))
21370 29095072 || types[p] == cSTEP)
21371 {
21372 706 hasStep[p] = true;
21373 706 break;
21374 }
21375 29094366 }
21376 4157044 }
21377 1039261 bool canNormalStep = true;
21378
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 1039573 times.
1039660 for(auto p = 0; p < 4; ++p)
21379 {
21380
2/2
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 1039371 times.
1039573 if(poses[p] < 0) continue;
21381
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 1039174 times.
1039371 if(!hasStep[p])
21382 {
21383 1039174 canNormalStep = false;
21384 1039174 break;
21385 }
21386 197 }
21387
2/2
✓ Branch 0 taken 4157044 times.
✓ Branch 1 taken 1039261 times.
5196305 for(auto p = 0; p < 4; ++p)
21388 {
21389
2/2
✓ Branch 0 taken 29099308 times.
✓ Branch 1 taken 4157044 times.
33256352 for(auto lyr = 0; lyr < 7; ++lyr)
21390 {
21391
2/2
✓ Branch 0 taken 14124880 times.
✓ Branch 1 taken 14974428 times.
29099308 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
21392
2/2
✓ Branch 0 taken 11635890 times.
✓ Branch 1 taken 17463418 times.
29099308 newcombo const* cmb2 = sensPoses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[sensPoses[p]]];
21393
5/6
✓ Branch 0 taken 2436 times.
✓ Branch 1 taken 29096872 times.
✓ Branch 2 taken 1064 times.
✓ Branch 3 taken 1372 times.
✓ Branch 4 taken 1064 times.
✗ Branch 5 not taken.
29099308 if(canNormalStep && cmb && (cmb->triggerflags[0] & combotriggerSTEP))
21394 {
21395 do_trigger_combo(lyr,poses[p]);
21396 if(poses[p] == sensPoses[p]) continue;
21397 }
21398
3/4
✓ Branch 0 taken 11635890 times.
✓ Branch 1 taken 17463418 times.
✓ Branch 2 taken 11635890 times.
✗ Branch 3 not taken.
29099308 if(cmb2 && (cmb2->triggerflags[0] & combotriggerSTEPSENS))
21399 {
21400 do_trigger_combo(lyr,sensPoses[p]);
21401 }
21402 29099308 }
21403 4157044 }
21404 1039261 word c = tmpscr->numFFC();
21405
2/2
✓ Branch 0 taken 29561595 times.
✓ Branch 1 taken 1039261 times.
30600856 for(word i=0; i<c; i++)
21406 {
21407 29561595 bool found = false;
21408
2/2
✓ Branch 0 taken 59123190 times.
✓ Branch 1 taken 29561595 times.
88684785 for(auto xch = 0; xch < 2; ++xch)
21409 {
21410
2/2
✓ Branch 0 taken 118246380 times.
✓ Branch 1 taken 59123190 times.
177369570 for(auto ych = 0; ych < 2; ++ych)
21411 {
21412
2/2
✓ Branch 0 taken 118219463 times.
✓ Branch 1 taken 26917 times.
118246380 if (ffcIsAt(i, xPoses[xch], yPoses[ych]))
21413 {
21414 26917 found = true;
21415 26917 }
21416 118246380 }
21417 59123190 }
21418
2/2
✓ Branch 0 taken 29548640 times.
✓ Branch 1 taken 12955 times.
29561595 if (found)
21419 {
21420 12955 ffcdata& ffc = tmpscr->ffcs[i];
21421 12955 newcombo const* cmb = &combobuf[ffc.getData()];
21422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12955 times.
12955 if (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS))
21423 {
21424 do_trigger_combo_ffc(i);
21425 }
21426 12955 }
21427 29561595 }
21428 1039261 }
21429
21430 //
21431 // Now, let's check for Save combos...
21432 //
21433 1050815 x1 = tx+4;
21434 1050815 x2 = tx+11;
21435 1050815 y1 = ty+4;
21436 1050815 y2 = ty+11;
21437
21438 1050815 types[0] = COMBOTYPE(x1,y1);
21439 1050815 cids[0] = MAPCOMBO(x1,y1);
21440
21441
2/2
✓ Branch 0 taken 1042339 times.
✓ Branch 1 taken 8476 times.
1050815 if(MAPFFCOMBO(x1,y1))
21442 {
21443 8476 types[0] = FFCOMBOTYPE(x1,y1);
21444 8476 cids[0] = MAPFFCOMBO(x1,y1);
21445 8476 }
21446
21447 1050815 types[1] = COMBOTYPE(x1,y2);
21448 1050815 cids[1] = MAPCOMBO(x1,y2);
21449
21450
2/2
✓ Branch 0 taken 1046079 times.
✓ Branch 1 taken 4736 times.
1050815 if(MAPFFCOMBO(x1,y2))
21451 {
21452 4736 types[1] = FFCOMBOTYPE(x1,y2);
21453 4736 cids[1] = MAPFFCOMBO(x1,y2);
21454 4736 }
21455
21456 1050815 types[2] = COMBOTYPE(x2,y1);
21457 1050815 cids[2] = MAPCOMBO(x2,y1);
21458
21459
2/2
✓ Branch 0 taken 1042808 times.
✓ Branch 1 taken 8007 times.
1050815 if(MAPFFCOMBO(x2,y1))
21460 {
21461 8007 types[2] = FFCOMBOTYPE(x2,y1);
21462 8007 cids[2] = MAPFFCOMBO(x2,y1);
21463 8007 }
21464
21465 1050815 types[3] = COMBOTYPE(x2,y2);
21466 1050815 cids[3] = MAPCOMBO(x2,y2);
21467
21468
2/2
✓ Branch 0 taken 1046533 times.
✓ Branch 1 taken 4282 times.
1050815 if(MAPFFCOMBO(x2,y2))
21469 {
21470 4282 types[3] = FFCOMBOTYPE(x2,y2);
21471 4282 cids[3] = MAPFFCOMBO(x2,y2);
21472 4282 }
21473
21474
21475
2/2
✓ Branch 0 taken 1050815 times.
✓ Branch 1 taken 4203260 times.
5254075 for(int32_t i=0; i<4; i++)
21476 {
21477
1/2
✓ Branch 0 taken 4203260 times.
✗ Branch 1 not taken.
4203260 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
21478 {
21479 if(types[i] == cSAVE || types[i] == cSAVE2)
21480 {
21481 types[i] = cNONE;
21482 setsave = false;
21483 break;
21484 }
21485 }
21486
2/2
✓ Branch 0 taken 4201974 times.
✓ Branch 1 taken 1286 times.
4203260 if(types[i]==cSAVE) setsave=true;
21487
21488
1/2
✓ Branch 0 taken 4203260 times.
✗ Branch 1 not taken.
4203260 if(types[i]==cSAVE2) setsave=true;
21489 4203260 }
21490
21491
8/8
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 1050384 times.
✓ Branch 2 taken 343 times.
✓ Branch 3 taken 88 times.
✓ Branch 4 taken 335 times.
✓ Branch 5 taken 8 times.
✓ Branch 6 taken 106 times.
✓ Branch 7 taken 229 times.
1050815 if(setsave && types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21492 {
21493 229 last_savepoint_id = cids[0];
21494 229 type = types[0];
21495 229 }
21496 //
21497 // Now, let's check for Drowning combos...
21498 //
21499
3/4
✓ Branch 0 taken 656331 times.
✓ Branch 1 taken 394484 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 656331 times.
1050815 if(get_bit(quest_rules,qr_DROWN) || CanSideSwim())
21500 {
21501 394484 y1 = ty+9;
21502 394484 y2 = ty+15;
21503
2/2
✓ Branch 0 taken 218982 times.
✓ Branch 1 taken 175502 times.
394484 if (get_bit(quest_rules, qr_SMARTER_WATER))
21504 {
21505
4/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 217094 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1598 times.
220583 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
21506
2/2
✓ Branch 0 taken 1724 times.
✓ Branch 1 taken 164 times.
1888 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
21507
2/2
✓ Branch 0 taken 1601 times.
✓ Branch 1 taken 123 times.
1724 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
21508 1601 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
21509 218982 }
21510 else
21511 {
21512 175502 types[0] = COMBOTYPE(x1,y1);
21513
21514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 175502 times.
175502 if(MAPFFCOMBO(x1,y1))
21515 types[0] = FFCOMBOTYPE(x1,y1);
21516
21517 175502 types[1] = COMBOTYPE(x1,y2);
21518
21519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 175502 times.
175502 if(MAPFFCOMBO(x1,y2))
21520 types[1] = FFCOMBOTYPE(x1,y2);
21521
21522 175502 types[2] = COMBOTYPE(x2,y1);
21523
21524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 175502 times.
175502 if(MAPFFCOMBO(x2,y1))
21525 types[2] = FFCOMBOTYPE(x2,y1);
21526
21527 175502 types[3] = COMBOTYPE(x2,y2);
21528
21529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 175502 times.
175502 if(MAPFFCOMBO(x2,y2))
21530 types[3] = FFCOMBOTYPE(x2,y2);
21531
21532 175502 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
21533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 175502 times.
175502 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
21534 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
21535
21536
5/6
✓ Branch 0 taken 1892 times.
✓ Branch 1 taken 173610 times.
✓ Branch 2 taken 1888 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 1852 times.
✗ Branch 5 not taken.
177354 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
21537
3/4
✓ Branch 0 taken 1852 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 1852 times.
✗ Branch 3 not taken.
1888 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
21538 1852 water = typec;
21539 }
21540 394484 }
21541
21542
21543 // Pits have a bigger 'hitbox' than stairs...
21544 1050815 x1 = tx+7;
21545 1050815 x2 = tx+8;
21546 1050815 y1 = ty+7+(bigHitbox?0:4);
21547 1050815 y2 = ty+8+(bigHitbox?0:4);
21548
21549 1050815 types[0] = COMBOTYPE(x1,y1);
21550 1050815 cids[0] = MAPCOMBO(x1,y1);
21551
21552
2/2
✓ Branch 0 taken 1046251 times.
✓ Branch 1 taken 4564 times.
1050815 if(MAPFFCOMBO(x1,y1))
21553 {
21554 4564 types[0] = FFCOMBOTYPE(x1,y1);
21555 4564 cids[0] = MAPFFCOMBO(x1,y1);
21556 4564 }
21557
21558 1050815 types[1] = COMBOTYPE(x1,y2);
21559 1050815 cids[1] = MAPCOMBO(x1,y2);
21560
21561
2/2
✓ Branch 0 taken 1046270 times.
✓ Branch 1 taken 4545 times.
1050815 if(MAPFFCOMBO(x1,y2))
21562 {
21563 4545 types[1] = FFCOMBOTYPE(x1,y2);
21564 4545 cids[1] = MAPFFCOMBO(x1,y2);
21565 4545 }
21566 1050815 types[2] = COMBOTYPE(x2,y1);
21567 1050815 cids[2] = MAPCOMBO(x2,y1);
21568
21569
2/2
✓ Branch 0 taken 1046558 times.
✓ Branch 1 taken 4257 times.
1050815 if(MAPFFCOMBO(x2,y1))
21570 {
21571 4257 types[2] = FFCOMBOTYPE(x2,y1);
21572 4257 cids[2] = MAPFFCOMBO(x2,y1);
21573 4257 }
21574
21575 1050815 types[3] = COMBOTYPE(x2,y2);
21576 1050815 cids[3] = MAPCOMBO(x2,y2);
21577
21578
2/2
✓ Branch 0 taken 1046577 times.
✓ Branch 1 taken 4238 times.
1050815 if(MAPFFCOMBO(x2,y2))
21579 {
21580 4238 types[3] = FFCOMBOTYPE(x2,y2);
21581 4238 cids[3] = MAPFFCOMBO(x2,y2);
21582 4238 }
21583
21584
2/2
✓ Branch 0 taken 4203260 times.
✓ Branch 1 taken 1050815 times.
5254075 for(int32_t i=0; i<4; i++)
21585 {
21586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4203260 times.
4203260 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
21587 {
21588 types[i] = cNONE;
21589 continue;
21590 }
21591
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 4203134 times.
4203260 if(types[i]==cPIT)
21592 {
21593 126 index=0;
21594 126 warpsfx2 = combobuf[cids[i]].attribytes[0];
21595 126 }
21596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4203134 times.
4203134 else if(types[i]==cPITB)
21597 {
21598 types[i]=cPIT;
21599 index=1;
21600 warpsfx2 = combobuf[cids[i]].attribytes[0];
21601 }
21602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4203134 times.
4203134 else if(types[i]==cPITC)
21603 {
21604 types[i]=cPIT;
21605 index=2;
21606 warpsfx2 = combobuf[cids[i]].attribytes[0];
21607 }
21608
1/2
✓ Branch 0 taken 4203134 times.
✗ Branch 1 not taken.
4203134 else if(types[i]==cPITD)
21609 {
21610 types[i]=cPIT;
21611 index=3;
21612 warpsfx2 = combobuf[cids[i]].attribytes[0];
21613 }
21614 4203260 }
21615
21616
6/8
✓ Branch 0 taken 1050784 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 1050784 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1050783 times.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1050783 times.
1050815 if(types[0]==cPIT||types[1]==cPIT||types[2]==cPIT||types[3]==cPIT)
21617
3/8
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 32 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
64 if(action!=freeze&&action!=sideswimfreeze&& (!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
21618 32 type=cPIT;
21619
21620 //
21621 // Time to act on our results for type, flag, flag2 and flag3...
21622 //
21623
3/4
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 1050586 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 229 times.
1050815 if(type==cSAVE&&currscr<128)
21624 229 *ls=1;
21625
21626
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1050815 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1050815 if(type==cSAVE2&&currscr<128)
21627 *ls=2;
21628
21629
7/8
✓ Branch 0 taken 1045015 times.
✓ Branch 1 taken 5800 times.
✓ Branch 2 taken 1037887 times.
✓ Branch 3 taken 7128 times.
✓ Branch 4 taken 1037357 times.
✓ Branch 5 taken 530 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1037357 times.
1050815 if(refilling==REFILL_LIFE || flag==mfFAIRY||flag2==mfFAIRY||flag3==mfFAIRY)
21630 {
21631 13458 fairycircle(REFILL_LIFE);
21632
21633
2/2
✓ Branch 0 taken 11551 times.
✓ Branch 1 taken 1907 times.
13458 if(fairyclk!=0) return;
21634 1907 }
21635
21636
4/8
✓ Branch 0 taken 1039264 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1039264 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1039264 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1039264 times.
1039264 if(refilling==REFILL_MAGIC || flag==mfMAGICFAIRY||flag2==mfMAGICFAIRY||flag3==mfMAGICFAIRY)
21637 {
21638 fairycircle(REFILL_MAGIC);
21639
21640 if(fairyclk!=0) return;
21641 }
21642
21643
4/8
✓ Branch 0 taken 1039264 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1039264 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1039264 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1039264 times.
1039264 if(refilling==REFILL_ALL || flag==mfALLFAIRY||flag2==mfALLFAIRY||flag3==mfALLFAIRY)
21644 {
21645 fairycircle(REFILL_ALL);
21646
21647 if(fairyclk!=0) return;
21648 }
21649
21650 // Just in case Hero was moved off of the fairy flag
21651
1/2
✓ Branch 0 taken 1039264 times.
✗ Branch 1 not taken.
1039264 if(refilling==REFILL_FAIRYDONE)
21652 {
21653 fairycircle(REFILL_NONE);
21654
21655 if(fairyclk!=0) return;
21656 }
21657
21658
5/8
✓ Branch 0 taken 1039260 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1039260 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1039260 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1039260 times.
1039264 if(flag==mfZELDA||flag2==mfZELDA||flag3==mfZELDA || combo_class_buf[type].win_game)
21659 {
21660 4 attackclk = 0; //get rid of Hero's sword if it was stuck out, charged.
21661 4 win_game();
21662 4 return;
21663 }
21664
21665
4/4
✓ Branch 0 taken 1036060 times.
✓ Branch 1 taken 3200 times.
✓ Branch 2 taken 1036060 times.
✓ Branch 3 taken 3200 times.
1039260 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS))
21666 3200 return;
21667
21668
3/4
✓ Branch 0 taken 1036060 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1036059 times.
1036060 if((type==cTRIGNOFLAG || type==cTRIGFLAG))
21669 {
21670
21671
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepsecret || get_bit(quest_rules,qr_TRIGGERSREPEAT))
21672 {
21673 1 stepsecret = (((ty+8)&0xF0)+((tx+8)>>4));
21674 1 sfx(combobuf[tmpscr->data[stepsecret]].attribytes[0],pan((int32_t)x));
21675 //zprint("Step Secrets Sound: %d\n", combobuf[tmpscr->data[stepsecret]].attribytes[0]);
21676
21677
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(type==cTRIGFLAG && canPermSecret())
21678 {
21679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
21680
21681 1 hidden_entrance(0,true,false);
21682 1 }
21683 else
21684 {
21685 bool only16_31 = get_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
21686 hidden_entrance(0,true,only16_31);
21687 }
21688 1 }
21689 1 }
21690
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 1035717 times.
1036059 else if(!didstrig)
21691 {
21692 1035717 stepsecret = -1;
21693 1035717 }
21694
21695 //Better? Dock collision
21696
21697 // Drown if:
21698 // * Water (obviously walkable),
21699 // * Quest Rule allows it,
21700 // * Not on stepladder,
21701 // * Not jumping,
21702 // * Not hovering,
21703 // * Not rafting,
21704 // * Not swallowed,
21705 // * Not a dried lake.
21706
21707 // This used to check for swimming too, but I moved that into the block so that you can drown in higher-leveled water. -Dimi
21708
21709
13/22
✓ Branch 0 taken 3394 times.
✓ Branch 1 taken 1032666 times.
✓ Branch 2 taken 3394 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3394 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3394 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3394 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 3387 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3011 times.
✓ Branch 15 taken 376 times.
✓ Branch 16 taken 3011 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 3011 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1036060 if(water > 0 && ((get_bit(quest_rules,qr_DROWN) && z==0 && fakez==0 && fall>=0 && fakefall>=0) || CanSideSwim()) && !ladderx && hoverclk==0 && action!=rafting && !inlikelike && !DRIEDLAKE)
21710 {
21711
4/8
✓ Branch 0 taken 3000 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 3000 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3000 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3011 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
21712 {
21713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!(ladderx+laddery)) drownCombo = water;
21714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (combobuf[water].usrflags&cflag1) Drown(1);
21715 11 else Drown();
21716
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 8 times.
11 if(byte drown_sfx = combobuf[water].attribytes[4])
21717 8 sfx(drown_sfx, pan(int32_t(x)));
21718 11 }
21719
2/2
✓ Branch 0 taken 2891 times.
✓ Branch 1 taken 109 times.
3000 else if (!isSwimming())
21720 {
21721 109 SetSwim();
21722
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if (!IsSideSwim()) attackclk = charging = spins = 0;
21723 109 landswim=0;
21724 109 return;
21725 }
21726 2902 }
21727
21728
21729
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 1035788 times.
1035951 if(type==cSTEP)
21730 {
21731 //zprint2("Hero.HasHeavyBoots(): is: %s\n", ( (Hero.HasHeavyBoots()) ? "true" : "false" ));
21732
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 66 times.
163 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepnext)
21733 {
21734 66 stepnext=((ty+8)&0xF0)+((tx+8)>>4);
21735
21736 if
21737 (
21738
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 4 times.
66 COMBOTYPE(tx+8,ty+8)==cSTEP && /*required item*/
21739
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 (!combobuf[tmpscr->data[stepnext]].attribytes[1] || (combobuf[tmpscr->data[stepnext]].attribytes[1] && game->item[combobuf[tmpscr->data[stepnext]].attribytes[1]]) )
21740 && /*HEAVY*/
21741
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
21742 )
21743
21744 {
21745 62 sfx(combobuf[tmpscr->data[stepnext]].attribytes[0],pan((int32_t)x));
21746 62 tmpscr->data[stepnext]++;
21747
21748 62 }
21749
21750 if
21751 (
21752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 COMBOTYPE(tx+8,ty+8)==cSTEPSAME && /*required item*/
21753 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
21754 && /*HEAVY*/
21755 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
21756 )
21757 {
21758 int32_t stepc = tmpscr->data[stepnext];
21759 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
21760 for(int32_t k=0; k<176; k++)
21761 {
21762 if(tmpscr->data[k]==stepc)
21763 {
21764 tmpscr->data[k]++;
21765 }
21766 }
21767 }
21768
21769 if
21770 (
21771
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 63 times.
66 COMBOTYPE(tx+8,ty+8)==cSTEPALL && /*required item*/
21772
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
21773 && /*HEAVY*/
21774
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
21775 )
21776 {
21777 3 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
21778
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
531 for(int32_t k=0; k<176; k++)
21779 {
21780 if(
21781
3/4
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 507 times.
1050 (combobuf[tmpscr->data[k]].type==cSTEP)||
21782
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 (combobuf[tmpscr->data[k]].type==cSTEPSAME)||
21783
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 6 times.
528 (combobuf[tmpscr->data[k]].type==cSTEPALL)||
21784 522 (combobuf[tmpscr->data[k]].type==cSTEPCOPY)
21785 )
21786 {
21787 21 tmpscr->data[k]++;
21788 21 }
21789 528 }
21790 3 }
21791 66 }
21792 163 }
21793
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1035788 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1035788 else if(type==cSTEPSFX && action == walking)
21794 {
21795 trigger_stepfx(0, COMBOPOS(tx+8,ty+8), true);
21796 }
21797 1035788 else stepnext = -1;
21798
21799 1035951 detail_int[0]=tx;
21800 1035951 detail_int[1]=ty;
21801
21802
21803
6/8
✓ Branch 0 taken 1035809 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 169 times.
✓ Branch 3 taken 1035782 times.
✓ Branch 4 taken 1035195 times.
✓ Branch 5 taken 587 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1035951 if(!((type==cCAVE || type==cCAVE2) && z==0 && fakez==0) && type!=cSTAIR &&
21804
5/6
✓ Branch 0 taken 1035163 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 1035158 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 1035158 times.
✗ Branch 5 not taken.
1035195 type!=cPIT && type!=cSWIMWARP && type!=cRESET &&
21805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1035158 times.
1035158 !(type==cDIVEWARP && isDiving()))
21806 1035158 {
21807 RaftingStuff:
21808
2/2
✓ Branch 0 taken 1034599 times.
✓ Branch 1 taken 559 times.
1035158 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
21809 {
21810 559 bool doraft = true;
21811
4/6
✓ Branch 0 taken 559 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 556 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
559 if(((int32_t)y>=raftwarpy-12&&(int32_t)y<=raftwarpy+3)&&raftwarpy!=-1)
21812 {
21813
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
21814 {
21815 3 doraft = false;
21816 3 }
21817 3 }
21818 //if (mfRAFT)
21819 int32_t rafttypes[2];
21820 559 int32_t raftx1 = tx+6;
21821 559 int32_t raftx2 = tx+9;
21822 559 int32_t rafty = ty+11;
21823 int32_t raftflags[3];
21824 559 rafttypes[0]=rafttypes[1]=-1;
21825 559 raftflags[0]=raftflags[1]=raftflags[2]=0;
21826 559 rafttypes[0] = MAPFLAG(raftx1,rafty);
21827 559 rafttypes[1] = MAPFLAG(raftx2,rafty);
21828
21829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
21830 559 raftflags[0] = rafttypes[0];
21831
21832
21833 559 rafttypes[0] = MAPCOMBOFLAG(raftx1,rafty);
21834 559 rafttypes[1] = MAPCOMBOFLAG(raftx2,rafty);
21835
21836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
21837 559 raftflags[1] = rafttypes[0];
21838
21839 559 rafttypes[0] = MAPFFCOMBOFLAG(raftx1,rafty);
21840 559 rafttypes[1] = MAPFFCOMBOFLAG(raftx2,rafty);
21841
21842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
21843 559 raftflags[2] = rafttypes[0];
21844
21845
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 559 times.
2236 for (int32_t m = 0; m < 3; ++m)
21846 {
21847
2/4
✓ Branch 0 taken 1677 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1677 times.
1677 if (raftflags[m] == mfRAFT || raftflags[m] == mfRAFT_BRANCH)
21848 {
21849 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && (combo_class_buf[COMBOTYPE(tx+8, ty+11)].dock || combo_class_buf[FFCOMBOTYPE(tx+8, ty+11)].dock))
21850 {
21851 if((isRaftFlag(nextflag(tx,ty+11,dir,false))||isRaftFlag(nextflag(tx,ty+11,dir,true))))
21852 {
21853 reset_swordcharge();
21854 action=rafting; FFCore.setHeroAction(rafting);
21855 raftclk=0;
21856 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21857 else sfx(tmpscr->secretsfx);
21858 }
21859 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
21860 {
21861 for (int32_t i = 0; i < 4; ++i)
21862 {
21863 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,true)))
21864 {
21865 reset_swordcharge();
21866 action=rafting; FFCore.setHeroAction(rafting);
21867 raftclk=0;
21868 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21869 else sfx(tmpscr->secretsfx);
21870 dir = i;
21871 break;
21872 }
21873 }
21874 }
21875 }
21876 }
21877 1677 }
21878 559 }
21879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1035158 times.
1035158 if (RaftPass) return;
21880
3/3
✓ Branch 0 taken 2714 times.
✓ Branch 1 taken 1032041 times.
✓ Branch 2 taken 403 times.
1035158 switch(flag)
21881 {
21882 case mfDIVE_ITEM:
21883
6/8
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 396 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
403 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
21884 {
21885 8 additem(x, y, tmpscr->catchall,
21886 4 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
21887 4 sfx(tmpscr->secretsfx);
21888 4 }
21889
21890 403 return;
21891
21892 case mfRAFT:
21893 case mfRAFT_BRANCH:
21894
21895 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
21896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2714 times.
2714 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
21897 {
21898 2714 bool doraft = true;
21899
5/6
✓ Branch 0 taken 2714 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 494 times.
✓ Branch 3 taken 2220 times.
✓ Branch 4 taken 66 times.
✓ Branch 5 taken 428 times.
2714 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
21900 {
21901
4/6
✓ Branch 0 taken 428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 411 times.
✓ Branch 4 taken 17 times.
✗ Branch 5 not taken.
428 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
21902 {
21903 doraft = false;
21904 }
21905 428 }
21906
12/16
✓ Branch 0 taken 2512 times.
✓ Branch 1 taken 202 times.
✓ Branch 2 taken 359 times.
✓ Branch 3 taken 2153 times.
✓ Branch 4 taken 359 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 357 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 357 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 357 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 357 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 185 times.
✓ Branch 15 taken 172 times.
2714 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
21907 {
21908
3/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
172 if(isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true)))
21909 {
21910 132 reset_swordcharge();
21911 132 action=rafting; FFCore.setHeroAction(rafting);
21912 132 raftclk=0;
21913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21914 132 else sfx(tmpscr->secretsfx);
21915 132 }
21916
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
40 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
21917 {
21918 for (int32_t i = 0; i < 4; ++i)
21919 {
21920 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
21921 {
21922 reset_swordcharge();
21923 action=rafting; FFCore.setHeroAction(rafting);
21924 raftclk=0;
21925 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21926 else sfx(tmpscr->secretsfx);
21927 dir = i;
21928 break;
21929 }
21930 }
21931 }
21932 172 }
21933 2714 }
21934
21935 2714 return;
21936
21937 default:
21938 1032041 break;
21939 //return;
21940 }
21941
21942
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1032041 times.
✗ Branch 2 not taken.
1032041 switch(flag2)
21943 {
21944 case mfDIVE_ITEM:
21945 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
21946 {
21947 additem(x, y, tmpscr->catchall,
21948 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
21949 sfx(tmpscr->secretsfx);
21950 }
21951
21952 return;
21953
21954 case mfRAFT:
21955 case mfRAFT_BRANCH:
21956
21957 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
21958 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
21959 {
21960 bool doraft = true;
21961 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
21962 {
21963 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
21964 {
21965 doraft = false;
21966 }
21967 }
21968 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
21969 {
21970 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
21971 {
21972 reset_swordcharge();
21973 action=rafting; FFCore.setHeroAction(rafting);
21974 raftclk=0;
21975 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21976 else sfx(tmpscr->secretsfx);
21977 }
21978 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
21979 {
21980 for (int32_t i = 0; i < 4; ++i)
21981 {
21982 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
21983 {
21984 reset_swordcharge();
21985 action=rafting; FFCore.setHeroAction(rafting);
21986 raftclk=0;
21987 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
21988 else sfx(tmpscr->secretsfx);
21989 dir = i;
21990 break;
21991 }
21992 }
21993 }
21994 }
21995 }
21996
21997 return;
21998
21999 default:
22000 1032041 break;
22001 //return;
22002 }
22003
22004
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1032041 times.
✗ Branch 2 not taken.
1032041 switch(flag3)
22005 {
22006 case mfDIVE_ITEM:
22007 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
22008 {
22009 additem(x, y, tmpscr->catchall,
22010 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
22011 sfx(tmpscr->secretsfx);
22012 }
22013
22014 return;
22015
22016 case mfRAFT:
22017 case mfRAFT_BRANCH:
22018
22019 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
22020 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
22021 {
22022 bool doraft = true;
22023 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
22024 {
22025 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
22026 {
22027 doraft = false;
22028 }
22029 }
22030 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
22031 {
22032 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
22033 {
22034 reset_swordcharge();
22035 action=rafting; FFCore.setHeroAction(rafting);
22036 raftclk=0;
22037 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
22038 else sfx(tmpscr->secretsfx);
22039 }
22040 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
22041 {
22042 for (int32_t i = 0; i < 4; ++i)
22043 {
22044 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
22045 {
22046 reset_swordcharge();
22047 action=rafting; FFCore.setHeroAction(rafting);
22048 raftclk=0;
22049 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
22050 else sfx(tmpscr->secretsfx);
22051 dir = i;
22052 break;
22053 }
22054 }
22055 }
22056 }
22057 }
22058
22059 return;
22060
22061 default:
22062 1032041 return;
22063 }
22064 }
22065
22066
22067 793 int32_t t=(currscr<128)?0:1;
22068
22069
3/4
✓ Branch 0 taken 651 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 793 times.
✗ Branch 3 not taken.
793 if((type==cCAVE || type==cCAVE2) && (tmpscr[t].tilewarptype[index]==wtNOWARP)) return;
22070
22071 //don't do this for canceled warps -DD
22072 //I have no idea why we do this skip, but I'll dutifully propagate it to all cases below...
22073 /*if(tmpscr[t].tilewarptype[index] != wtNOWARP)
22074 {
22075 draw_screen(tmpscr);
22076 advanceframe(true);
22077 }*/
22078
22079 793 bool skippedaframe=false;
22080
22081
6/6
✓ Branch 0 taken 651 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 624 times.
✓ Branch 3 taken 27 times.
✓ Branch 4 taken 587 times.
✓ Branch 5 taken 37 times.
793 if(type==cCAVE || type==cCAVE2 || type==cSTAIR)
22082 {
22083 // Stop music only if:
22084 // * entering a Guy Cave
22085 // * warping to a DMap whose music is different.
22086
22087 756 int32_t tdm = tmpscr[t].tilewarpdmap[index];
22088
22089
2/2
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 193 times.
756 if(tmpscr[t].tilewarptype[index]<=wtPASS)
22090 {
22091
3/4
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 267 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 296 times.
563 if((DMaps[currdmap].flags&dmfCAVES) && tmpscr[t].tilewarptype[index] == wtCAVE)
22092 296 music_stop();
22093 563 }
22094 else
22095 {
22096
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 183 times.
193 if(zcmusic!=NULL)
22097 {
22098
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
20 if(strcmp(zcmusic->filename, DMaps[tdm].tmusic) != 0 ||
22099
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 (zcmusic->type==ZCMF_GME && zcmusic->track!=DMaps[tdm].tmusictrack))
22100 10 music_stop();
22101 10 }
22102
3/4
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 178 times.
183 else if(DMaps[tmpscr->tilewarpdmap[index]].midi != (currmidi-ZC_MIDI_COUNT+4) &&
22103 178 TheMaps[(DMaps[tdm].map*MAPSCRS + (tmpscr[t].tilewarpscr[index] + DMaps[tdm].xoff))].screen_midi != (currmidi-ZC_MIDI_COUNT+4))
22104 178 music_stop();
22105 }
22106
22107 756 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
22108
5/6
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 193 times.
✓ Branch 2 taken 296 times.
✓ Branch 3 taken 267 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 296 times.
756 bool opening = (tmpscr[t].tilewarptype[index]<=wtPASS && !(DMaps[currdmap].flags&dmfCAVES && tmpscr[t].tilewarptype[index]==wtCAVE)
22109 489 ? false : COOLSCROLL);
22110
22111 756 FFCore.warpScriptCheck();
22112 756 draw_screen(tmpscr);
22113 756 advanceframe(true);
22114
22115 756 skippedaframe=true;
22116
22117
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 729 times.
756 if(type==cCAVE2) walkup2(opening);
22118
2/2
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 142 times.
729 else if(type==cCAVE) walkdown(opening);
22119 756 }
22120
22121
2/2
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 32 times.
793 if(type==cPIT)
22122 {
22123 32 didpit=true;
22124 32 pitx=x;
22125 32 pity=y;
22126 32 warp_sound = warpsfx2;
22127 32 }
22128
22129
5/6
✓ Branch 0 taken 441 times.
✓ Branch 1 taken 352 times.
✓ Branch 2 taken 386 times.
✓ Branch 3 taken 55 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 55 times.
848 if(DMaps[currdmap].flags&dmf3STAIR && (currscr==129 || !(DMaps[currdmap].flags&dmfGUYCAVES))
22130
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
441 && tmpscr[specialcave > 0 && DMaps[currdmap].flags&dmfGUYCAVES ? 1:0].room==rWARP && type==cSTAIR)
22131 {
22132
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(!skippedaframe)
22133 {
22134 FFCore.warpScriptCheck();
22135 draw_screen(tmpscr);
22136 advanceframe(true);
22137 }
22138
22139 // "take any road you want"
22140
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 int32_t dw = x<112 ? 1 : (x>136 ? 3 : 2);
22141 55 int32_t code = WARPCODE(currdmap,homescr,dw);
22142
22143
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(code>-1)
22144 {
22145 55 bool changedlevel = false;
22146 55 bool changeddmap = false;
22147
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 15 times.
55 if(currdmap != code>>8)
22148 {
22149 15 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
22150 15 changeddmap = true;
22151 15 }
22152
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(dlevel != DMaps[code>>8].level)
22153 {
22154 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
22155 changedlevel = true;
22156 }
22157 55 currdmap = code>>8;
22158 55 dlevel = DMaps[currdmap].level;
22159
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 15 times.
55 if(changeddmap)
22160 {
22161 15 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
22162 15 }
22163
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if(changedlevel)
22164 {
22165 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
22166 }
22167
22168 55 currmap = DMaps[currdmap].map;
22169 55 homescr = (code&0xFF) + DMaps[currdmap].xoff;
22170 55 init_dmap();
22171
22172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(canPermSecret())
22173 55 setmapflag(mSECRET);
22174 55 }
22175
22176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(specialcave==STAIRCAVE) exitcave();
22177
22178 55 return;
22179 }
22180
22181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 738 times.
738 if(type==cRESET)
22182 {
22183 if(!skippedaframe)
22184 {
22185 FFCore.warpScriptCheck();
22186 draw_screen(tmpscr);
22187 advanceframe(true);
22188 }
22189
22190 if(!(tmpscr->noreset&mSECRET)) unsetmapflag(mSECRET);
22191
22192 if(!(tmpscr->noreset&mITEM)) unsetmapflag(mITEM);
22193
22194 if(!(tmpscr->noreset&mSPECIALITEM)) unsetmapflag(mSPECIALITEM);
22195
22196 if(!(tmpscr->noreset&mNEVERRET)) unsetmapflag(mNEVERRET);
22197
22198 if(!(tmpscr->noreset&mCHEST)) unsetmapflag(mCHEST);
22199
22200 if(!(tmpscr->noreset&mLOCKEDCHEST)) unsetmapflag(mLOCKEDCHEST);
22201
22202 if(!(tmpscr->noreset&mBOSSCHEST)) unsetmapflag(mBOSSCHEST);
22203
22204 if(!(tmpscr->noreset&mLOCKBLOCK)) unsetmapflag(mLOCKBLOCK);
22205
22206 if(!(tmpscr->noreset&mBOSSLOCKBLOCK)) unsetmapflag(mBOSSLOCKBLOCK);
22207
22208 if(isdungeon())
22209 {
22210 if(!(tmpscr->noreset&mDOOR_LEFT)) unsetmapflag(mDOOR_LEFT);
22211
22212 if(!(tmpscr->noreset&mDOOR_RIGHT)) unsetmapflag(mDOOR_RIGHT);
22213
22214 if(!(tmpscr->noreset&mDOOR_DOWN)) unsetmapflag(mDOOR_DOWN);
22215
22216 if(!(tmpscr->noreset&mDOOR_UP)) unsetmapflag(mDOOR_UP);
22217 }
22218
22219 didpit=true;
22220 pitx=x;
22221 pity=y;
22222 sdir=dir;
22223 dowarp(4,0, warpsfx2);
22224 }
22225 else
22226 {
22227
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 701 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
738 if(!skippedaframe && (tmpscr[t].tilewarptype[index]!=wtNOWARP))
22228 {
22229 37 FFCore.warpScriptCheck();
22230 37 draw_screen(tmpscr);
22231 37 advanceframe(true);
22232 37 }
22233
22234 738 sdir = dir;
22235 738 dowarp(0,index, warpsfx2);
22236 }
22237 3390519 }
22238
22239 21 int32_t selectWlevel(int32_t d)
22240 {
22241
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(TriforceCount()==0)
22242 return 0;
22243
22244 21 word l = game->get_wlevel();
22245
22246 21 do
22247 {
22248
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50 if(d==0 && (game->lvlitems[l+1] & liTRIFORCE))
22249 break;
22250
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 18 times.
50 else if(d<0)
22251
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 3 times.
18 l = (l==0) ? 7 : l-1;
22252 else
22253
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 28 times.
32 l = (l==7) ? 0 : l+1;
22254
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 21 times.
50 }
22255 50 while(!(game->lvlitems[l+1] & liTRIFORCE));
22256
22257 21 game->set_wlevel(l);
22258 21 return l;
22259 21 }
22260
22261 // Would someone tell the Dodongos to shut their yaps?!
22262 5385 void kill_enemy_sfx()
22263 {
22264
2/2
✓ Branch 0 taken 5385 times.
✓ Branch 1 taken 10500 times.
15885 for(int32_t i=0; i<guys.Count(); i++)
22265 {
22266
2/2
✓ Branch 0 taken 6402 times.
✓ Branch 1 taken 4098 times.
10500 if(((enemy*)guys.spr(i))->bgsfx)
22267 4098 stop_sfx(((enemy*)guys.spr(i))->bgsfx);
22268 10500 }
22269
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 5365 times.
5385 if (Hero.action!=inwind) stop_sfx(WAV_ZN1WHIRLWIND);
22270
2/2
✓ Branch 0 taken 5380 times.
✓ Branch 1 taken 5 times.
5385 if(tmpscr->room==rGANON)
22271 5 stop_sfx(WAV_ROAR);
22272 5385 }
22273
22274 675 bool HeroClass::HasHeavyBoots()
22275 {
22276
2/2
✓ Branch 0 taken 675 times.
✓ Branch 1 taken 172800 times.
173475 for ( int32_t q = 0; q < MAXITEMS; ++q )
22277 {
22278
5/6
✓ Branch 0 taken 1999 times.
✓ Branch 1 taken 170801 times.
✓ Branch 2 taken 649 times.
✓ Branch 3 taken 1350 times.
✓ Branch 4 taken 649 times.
✗ Branch 5 not taken.
172800 if ( game->item[q] && ( itemsbuf[q].family == itype_boots ) && /*iron*/ (itemsbuf[q].flags&ITEM_FLAG2) ) return true;
22279 172800 }
22280 675 return false;
22281 675 }
22282
22283 const char *roomtype_string[rMAX] =
22284 {
22285 "(None)","Special Item","Pay for Info","Secret Money","Gamble",
22286 "Door Repair","Red Potion or Heart Container","Feed the Goriya","Triforce Check",
22287 "Potion Shop","Shop","More Bombs","Leave Money or Life","10 Rupees",
22288 "3-Stair Warp","Ganon","Zelda", "-<item pond>", "1/2 Magic Upgrade", "Learn Slash", "More Arrows","Take One Item"
22289 };
22290
22291 984 bool HeroClass::dowarp(int32_t type, int32_t index, int32_t warpsfx)
22292 {
22293 984 byte reposition_sword_postwarp = 0;
22294
1/2
✓ Branch 0 taken 984 times.
✗ Branch 1 not taken.
984 if(index<0)
22295 {
22296 return false;
22297 }
22298 984 is_warping = true;
22299
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 984 times.
1100 for ( int32_t q = 0; q < Lwpns.Count(); ++q )
22300 {
22301 116 weapon *swd=NULL;
22302 116 swd = (weapon*)Lwpns.spr(q);
22303
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 8 times.
116 if(swd->id == (attack==wSword ? wSword : wWand))
22304 {
22305 8 Lwpns.del(q);
22306 8 }
22307 116 }
22308
22309 984 attackclk = charging = spins = tapping = 0;
22310 984 attack = none;
22311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 984 times.
984 if ( warp_sound > 0 ) warpsfx = warp_sound;
22312 984 warp_sound = 0;
22313 984 word wdmap=0;
22314 984 byte wscr=0,wtype=0,t=0;
22315 984 bool overlay=false;
22316 984 t=(currscr<128)?0:1;
22317 984 int32_t wrindex = 0;
22318 984 bool wasSideview = isSideViewGravity(t); // (tmpscr[t].flags7 & fSIDEVIEW)!=0 && !ignoreSideview;
22319
22320 // Drawing commands probably shouldn't carry over...
22321
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 978 times.
984 if ( !get_bit(quest_rules,qr_SCRIPTDRAWSINWARPS) )
22322 978 script_drawing_commands.Clear();
22323
22324
4/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 741 times.
✓ Branch 2 taken 217 times.
✓ Branch 3 taken 20 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
984 switch(type)
22325 {
22326 case 0: // tile warp
22327 741 wtype = tmpscr[t].tilewarptype[index];
22328 741 wdmap = tmpscr[t].tilewarpdmap[index];
22329 741 wscr = tmpscr[t].tilewarpscr[index];
22330 741 overlay = get_bit(&tmpscr[t].tilewarpoverlayflags,index)?1:0;
22331 741 wrindex=(tmpscr->warpreturnc>>(index*2))&3;
22332 741 break;
22333
22334 case 1: // side warp
22335 217 wtype = tmpscr[t].sidewarptype[index];
22336 217 wdmap = tmpscr[t].sidewarpdmap[index];
22337 217 wscr = tmpscr[t].sidewarpscr[index];
22338 217 overlay = get_bit(&tmpscr[t].sidewarpoverlayflags,index)?1:0;
22339 217 wrindex=(tmpscr->warpreturnc>>(8+(index*2)))&3;
22340 //tmpscr->doscript = 0; //kill the currebt screen's script so that it does not continue to run during the scroll.
22341 //there is no doscript for screen scripts. They run like ffcs.
22342
22343 217 break;
22344
22345 case 2: // whistle warp
22346 {
22347 20 wtype = wtWHISTLE;
22348
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 int32_t wind = whistleitem>-1 ? itemsbuf[whistleitem].misc2 : 8;
22349 20 int32_t level=0;
22350
22351
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(blowcnt==0)
22352 level = selectWlevel(0);
22353 else
22354 {
22355
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 20 times.
41 for(int32_t i=0; i<abs(blowcnt); i++)
22356 21 level = selectWlevel(blowcnt);
22357 }
22358
22359
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20 if(level > QMisc.warp[wind].size && QMisc.warp[wind].size>0)
22360 {
22361 level %= QMisc.warp[wind].size;
22362 game->set_wlevel(level);
22363 }
22364
22365 20 wdmap = QMisc.warp[wind].dmap[level];
22366 20 wscr = QMisc.warp[wind].scr[level];
22367 }
22368 20 break;
22369
22370 case 3:
22371 wtype = wtIWARP;
22372 wdmap = cheat_goto_dmap;
22373 wscr = cheat_goto_screen;
22374 break;
22375
22376 case 4:
22377 wtype = wtIWARP;
22378 wdmap = currdmap;
22379 wscr = homescr-DMaps[currdmap].xoff;
22380 break;
22381 }
22382
22383 984 bool intradmap = (wdmap == currdmap);
22384 984 int32_t olddmap = currdmap;
22385 984 rehydratelake(type!=wtSCROLL);
22386
22387
7/8
✓ Branch 0 taken 183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 338 times.
✓ Branch 3 taken 170 times.
✓ Branch 4 taken 188 times.
✓ Branch 5 taken 48 times.
✓ Branch 6 taken 20 times.
✓ Branch 7 taken 37 times.
984 switch(wtype)
22388 {
22389 case wtCAVE:
22390 {
22391 // cave/item room
22392 338 ALLOFF();
22393 338 homescr=currscr;
22394 338 currscr=0x80;
22395
22396
2/2
✓ Branch 0 taken 241 times.
✓ Branch 1 taken 97 times.
338 if(DMaps[currdmap].flags&dmfCAVES) // cave
22397 {
22398 241 music_stop();
22399 241 kill_sfx();
22400
22401
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 181 times.
241 if(tmpscr->room==rWARP)
22402 {
22403 60 currscr=0x81;
22404 60 specialcave = STAIRCAVE;
22405 60 }
22406 181 else specialcave = GUYCAVE;
22407
22408 //lighting(2,dir);
22409 241 lighting(false, true);
22410 241 loadlvlpal(10);
22411
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 38 times.
444 bool b2 = COOLSCROLL&&
22412
3/4
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 56 times.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
203 ((combobuf[MAPCOMBO(x,y-16)].type==cCAVE)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2)||
22413
2/4
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
147 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEB)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2B)||
22414
2/4
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
147 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEC)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2C)||
22415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 (combobuf[MAPCOMBO(x,y-16)].type==cCAVED)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2D));
22416 241 blackscr(30,b2?false:true);
22417 241 loadscr(0,wdmap,currscr,up,false);
22418 241 loadscr(1,wdmap,homescr,up,false);
22419 //preloaded freeform combos
22420 241 ffscript_engine(true);
22421 241 putscr(scrollbuf,0,0,tmpscr);
22422 241 putscrdoors(scrollbuf,0,0,tmpscr);
22423 241 dir=up;
22424 241 x=112;
22425 241 y=160;
22426
1/2
✓ Branch 0 taken 241 times.
✗ Branch 1 not taken.
241 if(didpit)
22427 {
22428 didpit=false;
22429 x=pitx;
22430 y=pity;
22431 }
22432
22433 241 reset_hookshot();
22434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 241 times.
241 if(reposition_sword_postwarp)
22435 {
22436 weapon *swd=NULL;
22437 for(int32_t i=0; i<Lwpns.Count(); i++)
22438 {
22439 swd = (weapon*)Lwpns.spr(i);
22440
22441 if(swd->id == (attack==wSword ? wSword : wWand))
22442 {
22443 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22444 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22445 positionSword(swd,item_id);
22446 break;
22447 }
22448 }
22449 }
22450 241 stepforward(diagonalMovement?5:6, false);
22451 241 }
22452 else // item room
22453 {
22454 97 specialcave = ITEMCELLAR;
22455 97 map_bkgsfx(false);
22456 97 kill_enemy_sfx();
22457 97 draw_screen(tmpscr,false);
22458
22459 //unless the room is already dark, fade to black
22460
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 96 times.
97 if(!darkroom)
22461 {
22462 96 darkroom = true;
22463 96 fade(DMaps[currdmap].color,true,false);
22464 96 }
22465
22466 97 blackscr(30,true);
22467 97 loadscr(0,wdmap,currscr,down,false);
22468 97 loadscr(1,wdmap,homescr,-1,false);
22469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if ( dontdraw < 2 ) { dontdraw=1; }
22470 97 draw_screen(tmpscr);
22471 97 fade(11,true,true);
22472 97 darkroom = false;
22473 97 dir=down;
22474 97 x=48;
22475 97 y=0;
22476
22477 // is this didpit check necessary?
22478
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(didpit)
22479 {
22480 didpit=false;
22481 x=pitx;
22482 y=pity;
22483 }
22484
22485 97 reset_hookshot();
22486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(reposition_sword_postwarp)
22487 {
22488 weapon *swd=NULL;
22489 for(int32_t i=0; i<Lwpns.Count(); i++)
22490 {
22491 swd = (weapon*)Lwpns.spr(i);
22492
22493 if(swd->id == (attack==wSword ? wSword : wWand))
22494 {
22495 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22496 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22497 positionSword(swd,item_id);
22498 break;
22499 }
22500 }
22501 }
22502 97 lighting(false, true);
22503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if ( dontdraw < 2 ) { dontdraw=0; }
22504 97 stepforward(diagonalMovement?16:18, false);
22505 }
22506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 338 times.
338 if (get_bit(quest_rules,qr_SCREEN80_OWN_MUSIC)) playLevelMusic();
22507 338 break;
22508 }
22509
22510 case wtPASS: // passageway
22511 {
22512 170 map_bkgsfx(false);
22513 170 kill_enemy_sfx();
22514 170 ALLOFF();
22515 //play sound
22516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170 times.
170 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
22517 170 homescr=currscr;
22518 170 currscr=0x81;
22519 170 specialcave = PASSAGEWAY;
22520 170 byte warpscr2 = wscr + DMaps[wdmap].xoff;
22521 170 draw_screen(tmpscr,false);
22522
22523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170 times.
170 if(!get_bit(quest_rules, qr_NEW_DARKROOM))
22524 {
22525
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 162 times.
170 if(!darkroom)
22526 162 fade(DMaps[currdmap].color,true,false);
22527
22528 170 darkroom=true;
22529 170 }
22530 170 blackscr(30,true);
22531 170 loadscr(0,wdmap,currscr,down,false);
22532 170 loadscr(1,wdmap,homescr,-1,false);
22533 //preloaded freeform combos
22534 170 ffscript_engine(true);
22535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170 times.
170 if ( dontdraw < 2 ) { dontdraw=1; }
22536 170 draw_screen(tmpscr);
22537 170 lighting(false, true);
22538 170 dir=down;
22539 170 x=48;
22540
22541
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 85 times.
170 if((homescr&15) > (warpscr2&15))
22542 {
22543 85 x=192;
22544 85 }
22545
22546
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 1 times.
170 if((homescr&15) == (warpscr2&15))
22547 {
22548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if((currscr>>4) > (warpscr2>>4))
22549 {
22550 1 x=192;
22551 1 }
22552 1 }
22553
22554 // is this didpit check necessary?
22555
1/2
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
170 if(didpit)
22556 {
22557 didpit=false;
22558 x=pitx;
22559 y=pity;
22560 }
22561
22562 170 y=0;
22563 170 set_respawn_point();
22564 170 trySideviewLadder();
22565 170 reset_hookshot();
22566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170 times.
170 if(reposition_sword_postwarp)
22567 {
22568 weapon *swd=NULL;
22569 for(int32_t i=0; i<Lwpns.Count(); i++)
22570 {
22571 swd = (weapon*)Lwpns.spr(i);
22572
22573 if(swd->id == (attack==wSword ? wSword : wWand))
22574 {
22575 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22576 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22577 positionSword(swd,item_id);
22578 break;
22579 }
22580 }
22581 }
22582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170 times.
170 if ( dontdraw < 2 ) { dontdraw=0; }
22583 170 stepforward(diagonalMovement?16:18, false);
22584 170 newscr_clk=frame;
22585 170 activated_timed_warp=false;
22586 170 stepoutindex=index;
22587 170 stepoutscr = warpscr2;
22588 170 stepoutdmap = wdmap;
22589 170 stepoutwr=wrindex;
22590 }
22591 170 break;
22592
22593 case wtEXIT: // entrance/exit
22594 {
22595 188 lighting(false,false,pal_litRESETONLY);//Reset permLit, and do nothing else; lighting was not otherwise called on a wtEXIT warp.
22596 188 ALLOFF();
22597 188 music_stop();
22598 188 kill_sfx();
22599 188 blackscr(30,false);
22600 188 bool changedlevel = false;
22601 188 bool changeddmap = false;
22602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 188 times.
188 if(currdmap != wdmap)
22603 {
22604 188 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
22605 188 changeddmap = true;
22606 188 }
22607
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 187 times.
188 if(dlevel != DMaps[wdmap].level)
22608 {
22609 187 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
22610 187 changedlevel = true;
22611 187 }
22612 188 dlevel = DMaps[wdmap].level;
22613 188 currdmap = wdmap;
22614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 188 times.
188 if(changeddmap)
22615 {
22616 188 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
22617 188 }
22618
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 187 times.
188 if(changedlevel)
22619 {
22620 187 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
22621 187 }
22622
22623 188 currmap=DMaps[currdmap].map;
22624 188 init_dmap();
22625 188 update_subscreens(wdmap);
22626 188 loadfullpal();
22627 188 ringcolor(false);
22628 188 loadlvlpal(DMaps[currdmap].color);
22629 //lastentrance_dmap = currdmap;
22630 188 homescr = currscr = wscr + DMaps[currdmap].xoff;
22631 188 loadscr(0,currdmap,currscr,-1,overlay);
22632
22633
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 185 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
188 if((tmpscr->flags&fDARK) && !get_bit(quest_rules,qr_NEW_DARKROOM))
22634 {
22635
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_bit(quest_rules,qr_FADE))
22636 {
22637 interpolatedfade();
22638 }
22639 else
22640 {
22641 3 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
22642 }
22643
22644 3 darkroom=naturaldark=true;
22645 3 }
22646 else
22647 {
22648 185 darkroom=naturaldark=false;
22649 }
22650
22651 int32_t wrx,wry;
22652
22653
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 174 times.
188 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22654 {
22655 14 wrx=tmpscr->warpreturnx[0];
22656 14 wry=tmpscr->warpreturny[0];
22657 14 }
22658 else
22659 {
22660 174 wrx=tmpscr->warparrivalx;
22661 174 wry=tmpscr->warparrivaly;
22662 }
22663
22664
6/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 150 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 26 times.
✓ Branch 5 taken 162 times.
188 if(((wrx>0||wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
22665 {
22666
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 58 times.
162 if(dlevel)
22667 {
22668 104 lastentrance = currscr;
22669 104 }
22670 else
22671 {
22672 58 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
22673 }
22674
22675 162 lastentrance_dmap = wdmap;
22676 162 }
22677
22678
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 84 times.
188 if(dlevel)
22679 {
22680
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 97 times.
104 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22681 {
22682 7 x=tmpscr->warpreturnx[wrindex];
22683 7 y=tmpscr->warpreturny[wrindex];
22684 7 }
22685 else
22686 {
22687 97 x=tmpscr->warparrivalx;
22688 97 y=tmpscr->warparrivaly;
22689 }
22690 104 }
22691 else
22692 {
22693 84 x=tmpscr->warpreturnx[wrindex];
22694 84 y=tmpscr->warpreturny[wrindex];
22695 }
22696
22697
1/2
✓ Branch 0 taken 188 times.
✗ Branch 1 not taken.
188 if(didpit)
22698 {
22699 didpit=false;
22700 x=pitx;
22701 y=pity;
22702 }
22703
22704 188 dir=down;
22705
22706
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 176 times.
188 if(x==0) dir=right;
22707
22708
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 180 times.
188 if(x==240) dir=left;
22709
22710
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 182 times.
188 if(y==0) dir=down;
22711
22712
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 110 times.
188 if(y==160) dir=up;
22713
22714
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 84 times.
188 if(dlevel)
22715 {
22716 // reset enemy kill counts
22717
2/2
✓ Branch 0 taken 13312 times.
✓ Branch 1 taken 104 times.
13416 for(int32_t i=0; i<128; i++)
22718 {
22719 13312 game->guys[(currmap*MAPSCRSNORMAL)+i] = 0;
22720 13312 game->maps[(currmap*MAPSCRSNORMAL)+i] &= ~mTMPNORET;
22721 13312 }
22722 104 }
22723
22724 188 markBmap(dir^1);
22725 //preloaded freeform combos
22726 188 ffscript_engine(true);
22727
22728 188 reset_hookshot();
22729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 188 times.
188 if(reposition_sword_postwarp)
22730 {
22731 weapon *swd=NULL;
22732 for(int32_t i=0; i<Lwpns.Count(); i++)
22733 {
22734 swd = (weapon*)Lwpns.spr(i);
22735
22736 if(swd->id == (attack==wSword ? wSword : wWand))
22737 {
22738 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22739 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22740 positionSword(swd,item_id);
22741 break;
22742 }
22743 }
22744 }
22745
22746
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 91 times.
188 if(isdungeon())
22747 {
22748 97 openscreen();
22749
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
97 if(get_bit(extra_rules, er_SHORTDGNWALK)==0 && get_bit(quest_rules, qr_SHORTDGNWALK)==0)
22750 97 stepforward(diagonalMovement?11:12, false);
22751 else
22752 // Didn't walk as far pre-1.93, and some quests depend on that
22753 stepforward(8, false);
22754 97 }
22755 else
22756 {
22757
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 68 times.
91 if(!COOLSCROLL)
22758 23 openscreen();
22759
22760 91 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type; // Old-style blue square placement
22761 91 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
22762 91 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type; // More old-style blue square placement
22763
22764
5/10
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
✓ Branch 4 taken 38 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 38 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
91 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
22765 {
22766 53 reset_pal_cycling();
22767 53 putscr(scrollbuf,0,0,tmpscr);
22768 53 putscrdoors(scrollbuf,0,0,tmpscr);
22769 53 walkup(COOLSCROLL);
22770 53 }
22771
5/10
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 35 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 35 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
38 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
22772 {
22773 3 reset_pal_cycling();
22774 3 putscr(scrollbuf,0,0,tmpscr);
22775 3 putscrdoors(scrollbuf,0,0,tmpscr);
22776 3 walkdown2(COOLSCROLL);
22777 3 }
22778
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 13 times.
35 else if(COOLSCROLL)
22779 {
22780 22 openscreen();
22781 22 }
22782 }
22783
22784 188 show_subscreen_life=true;
22785 188 show_subscreen_numbers=true;
22786 188 playLevelMusic();
22787 188 currcset=DMaps[currdmap].color;
22788 188 dointro();
22789 188 set_respawn_point();
22790 188 trySideviewLadder();
22791
22792
2/2
✓ Branch 0 taken 1128 times.
✓ Branch 1 taken 188 times.
1316 for(int32_t i=0; i<6; i++)
22793 1128 visited[i]=-1;
22794
22795 188 break;
22796 }
22797
22798 case wtSCROLL: // scrolling warp
22799 {
22800 48 int32_t c = DMaps[currdmap].color;
22801 48 scrolling_map = currmap;
22802 48 currmap = DMaps[wdmap].map;
22803 48 update_subscreens(wdmap);
22804
22805 48 dlevel = DMaps[wdmap].level;
22806 //check if Hero has the map for the new location before updating the subscreen. ? -Z
22807 //This works only in one direction, if Hero had a map, to not having one.
22808 //If Hero does not have a map, and warps somewhere where he does, then the map still briefly shows.
22809 48 update_subscreens(wdmap);
22810
22811 /*if ( has_item(itype_map, dlevel) )
22812 {
22813 //Blank the map during an intra-dmap scrolling warp.
22814 dlevel = -1; //a hack for the minimap. This works!! -Z
22815 }*/
22816
22817 // fix the scrolling direction, if it was a tile or instant warp
22818
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
48 if(type==0 || type>=3)
22819 {
22820 sdir = dir;
22821 }
22822
22823 48 scrollscr(sdir, wscr+DMaps[wdmap].xoff, wdmap);
22824 //dlevel = DMaps[wdmap].level; //Fix dlevel and draw the map (end hack). -Z
22825
22826 48 reset_hookshot();
22827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(reposition_sword_postwarp)
22828 {
22829 weapon *swd=NULL;
22830 for(int32_t i=0; i<Lwpns.Count(); i++)
22831 {
22832 swd = (weapon*)Lwpns.spr(i);
22833
22834 if(swd->id == (attack==wSword ? wSword : wWand))
22835 {
22836 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22837 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22838 positionSword(swd,item_id);
22839 break;
22840 }
22841 }
22842 }
22843
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 34 times.
48 if(!intradmap)
22844 {
22845 34 homescr = currscr = wscr + DMaps[wdmap].xoff;
22846 34 init_dmap();
22847
22848 int32_t wrx,wry;
22849
22850
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 14 times.
34 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22851 {
22852 20 wrx=tmpscr->warpreturnx[0];
22853 20 wry=tmpscr->warpreturny[0];
22854 20 }
22855 else
22856 {
22857 14 wrx=tmpscr->warparrivalx;
22858 14 wry=tmpscr->warparrivaly;
22859 }
22860
22861
7/8
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 18 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 10 times.
34 if(((wrx>0||wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))&&(!get_bit(quest_rules,qr_NOSCROLLCONTINUE))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
22862 {
22863
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 7 times.
10 if(dlevel)
22864 {
22865 3 lastentrance = currscr;
22866 3 }
22867 else
22868 {
22869 7 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
22870 }
22871
22872 10 lastentrance_dmap = wdmap;
22873 10 }
22874 34 }
22875
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 16 times.
48 if(DMaps[currdmap].color != c)
22876 {
22877 16 lighting(false, true);
22878 16 }
22879
22880 48 playLevelMusic();
22881 48 currcset=DMaps[currdmap].color;
22882 48 dointro();
22883 }
22884 48 break;
22885
22886 case wtWHISTLE: // whistle warp
22887 {
22888 20 scrolling_map = currmap;
22889 20 currmap = DMaps[wdmap].map;
22890 20 scrollscr(index, wscr+DMaps[wdmap].xoff, wdmap);
22891 20 reset_hookshot();
22892 20 currdmap=wdmap;
22893 20 dlevel=DMaps[currdmap].level;
22894 20 lighting(false, true);
22895 20 init_dmap();
22896
22897 20 playLevelMusic();
22898 20 currcset=DMaps[currdmap].color;
22899 20 dointro();
22900 20 action=inwind; FFCore.setHeroAction(inwind);
22901 int32_t wry;
22902
22903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22904 wry=tmpscr->warpreturny[0];
22905 20 else wry=tmpscr->warparrivaly;
22906
22907 int32_t wrx;
22908
22909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22910 wrx=tmpscr->warpreturnx[0];
22911 20 else wrx=tmpscr->warparrivalx;
22912
22913
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 20 times.
✓ Branch 10 taken 20 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 20 times.
✗ Branch 13 not taken.
40 Lwpns.add(new weapon((zfix)(index==left?240:index==right?0:wrx),(zfix)(index==down?0:index==up?160:wry),
22914
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 (zfix)0,wWind,1,0,index,whistleitem,getUID(),false,false,true,1));
22915 20 whirlwind=255;
22916 20 whistleitem=-1;
22917 }
22918 20 break;
22919
22920 case wtIWARP:
22921 case wtIWARPBLK:
22922 case wtIWARPOPEN:
22923 case wtIWARPZAP:
22924 case wtIWARPWAVE: // insta-warps
22925 {
22926 183 bool old_192 = false;
22927
1/2
✓ Branch 0 taken 183 times.
✗ Branch 1 not taken.
183 if (get_bit(quest_rules,qr_192b163_WARP))
22928 {
22929 if ( wtype == wtIWARPWAVE )
22930 {
22931 wtype = wtIWARPWAVE;
22932 old_192 = true;
22933 }
22934 if ( old_192 )
22935 {
22936 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Wave Warp.\n %s\n", "Trying to redirect it into a Cancel Effect");
22937 didpit=false;
22938 update_subscreens();
22939 warp_sound = 0;
22940 is_warping = false;
22941 return false;
22942 }
22943 }
22944 //for determining whether to exit cave
22945 183 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
22946 183 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
22947 183 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
22948
22949
8/8
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 168 times.
✓ Branch 4 taken 172 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 168 times.
359 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
22950
7/8
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 164 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 168 times.
✓ Branch 6 taken 165 times.
✓ Branch 7 taken 3 times.
172 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
22951
22952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
199 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
22953 {
22954 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
22955 177 bool wasswimming = (action == swimming);
22956 177 int32_t olddiveclk = diveclk;
22957 177 ALLOFF();
22958
22959
2/2
✓ Branch 0 taken 171 times.
✓ Branch 1 taken 6 times.
177 if(wasswimming)
22960 {
22961 6 Hero.SetSwim();
22962 6 diveclk = olddiveclk;
22963 6 }
22964
22965 177 kill_sfx();
22966 177 }
22967 //play sound
22968
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 42 times.
177 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
22969
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 165 times.
177 if(wtype==wtIWARPZAP)
22970 {
22971 12 zapout();
22972 12 }
22973
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 142 times.
165 else if(wtype==wtIWARPWAVE)
22974 {
22975 //only draw Hero if he's not in a cave -DD
22976 23 wavyout(!cavewarp);
22977 23 }
22978
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 81 times.
142 else if(wtype!=wtIWARP)
22979 {
22980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 bool b2 = COOLSCROLL&&cavewarp;
22981 81 blackscr(30,b2?false:true);
22982 81 }
22983
22984 177 int32_t c = DMaps[currdmap].color;
22985 177 bool changedlevel = false;
22986 177 bool changeddmap = false;
22987
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 152 times.
177 if(currdmap != wdmap)
22988 {
22989 152 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
22990 152 changeddmap = true;
22991 152 }
22992
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 32 times.
177 if(dlevel != DMaps[wdmap].level)
22993 {
22994 32 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
22995 32 changedlevel = true;
22996 32 }
22997 177 dlevel = DMaps[wdmap].level;
22998 177 currdmap = wdmap;
22999
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 152 times.
177 if(changeddmap)
23000 {
23001 152 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
23002 152 }
23003
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 32 times.
177 if(changedlevel)
23004 {
23005 32 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
23006 32 }
23007
23008 177 currmap = DMaps[currdmap].map;
23009 177 init_dmap();
23010 177 update_subscreens(wdmap);
23011
23012 177 ringcolor(false);
23013
23014
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 108 times.
177 if(DMaps[currdmap].color != c)
23015 108 loadlvlpal(DMaps[currdmap].color);
23016
23017 177 homescr = currscr = wscr + DMaps[currdmap].xoff;
23018
23019 177 lightingInstant(); // Also sets naturaldark
23020
23021 177 loadscr(0,currdmap,currscr,-1,overlay);
23022
23023 177 x = tmpscr->warpreturnx[wrindex];
23024 177 y = tmpscr->warpreturny[wrindex];
23025
23026
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 36 times.
177 if(didpit)
23027 {
23028 36 didpit=false;
23029 36 x=pitx;
23030 36 y=pity;
23031 36 }
23032
23033 177 type1 = combobuf[MAPCOMBO(x,y-16)].type;
23034 177 type2 = combobuf[MAPCOMBO(x,y)].type;
23035 177 type3 = combobuf[MAPCOMBO(x,y+16)].type;
23036
23037
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 2 times.
177 if(x==0) dir=right;
23038
23039
1/2
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
177 if(x==240) dir=left;
23040
23041
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 2 times.
177 if(y==0) dir=down;
23042
23043
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 14 times.
177 if(y==160) dir=up;
23044
23045 177 markBmap(dir^1);
23046
23047 177 int32_t checkwater = iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+(bigHitbox?8:12)); //iswaterex can be intensive, so let's avoid as many calls as we can.
23048
23049
10/16
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 5 times.
✓ Branch 12 taken 5 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 5 times.
✓ Branch 15 taken 172 times.
182 if(checkwater && _walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) && current_item(itype_flippers) > 0 && current_item(itype_flippers) >= combobuf[checkwater].attribytes[0] && (!(combobuf[checkwater].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
23050 {
23051 5 hopclk=0xFF;
23052 5 SetSwim();
23053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!IsSideSwim()) attackclk = charging = spins = 0;
23054 5 }
23055 else
23056 {
23057 172 action = none; FFCore.setHeroAction(none);
23058 }
23059 //preloaded freeform combos
23060 177 ffscript_engine(true);
23061
23062 177 putscr(scrollbuf,0,0,tmpscr);
23063 177 putscrdoors(scrollbuf,0,0,tmpscr);
23064
23065
10/10
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 172 times.
✓ Branch 4 taken 175 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 173 times.
✓ Branch 8 taken 6 times.
✓ Branch 9 taken 8 times.
177 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
23066 {
23067 14 reset_pal_cycling();
23068 14 putscr(scrollbuf,0,0,tmpscr);
23069 14 putscrdoors(scrollbuf,0,0,tmpscr);
23070 14 walkup(COOLSCROLL);
23071 14 }
23072
7/10
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 172 times.
✓ Branch 4 taken 175 times.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 175 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
181 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
23073 {
23074 12 reset_pal_cycling();
23075 12 putscr(scrollbuf,0,0,tmpscr);
23076 12 putscrdoors(scrollbuf,0,0,tmpscr);
23077 12 walkdown2(COOLSCROLL);
23078 12 }
23079
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 163 times.
175 else if(wtype==wtIWARPZAP)
23080 {
23081 12 zapin();
23082 12 }
23083
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 140 times.
163 else if(wtype==wtIWARPWAVE)
23084 {
23085 23 wavyin();
23086 23 }
23087
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 9 times.
140 else if(wtype==wtIWARPOPEN)
23088 {
23089 9 openscreen();
23090 9 }
23091
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(reposition_sword_postwarp)
23092 {
23093 weapon *swd=NULL;
23094 for(int32_t i=0; i<Lwpns.Count(); i++)
23095 {
23096 swd = (weapon*)Lwpns.spr(i);
23097
23098 if(swd->id == (attack==wSword ? wSword : wWand))
23099 {
23100 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23101 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23102 positionSword(swd,item_id);
23103 break;
23104 }
23105 }
23106 }
23107 189 show_subscreen_life=true;
23108 189 show_subscreen_numbers=true;
23109 189 playLevelMusic();
23110 189 currcset=DMaps[currdmap].color;
23111 189 dointro();
23112 189 set_respawn_point();
23113 189 trySideviewLadder();
23114 }
23115 189 break;
23116
23117
23118 case wtNOWARP:
23119 {
23120 37 bool old_192 = false;
23121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if (get_bit(quest_rules,qr_192b163_WARP))
23122 {
23123 wtype = wtIWARPWAVE;
23124 old_192 = true;
23125 }
23126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if ( old_192 )
23127 {
23128 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Cancel Warp.\n %s\n", "Trying to redirect it into a Wave Effect");
23129 //for determining whether to exit cave
23130 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
23131 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
23132 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
23133
23134 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
23135 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
23136
23137 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
23138 {
23139 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
23140 bool wasswimming = (action == swimming);
23141 int32_t olddiveclk = diveclk;
23142 ALLOFF();
23143
23144 if(wasswimming)
23145 {
23146 Hero.SetSwim();
23147 diveclk = olddiveclk;
23148 }
23149
23150 kill_sfx();
23151 }
23152 //play sound
23153 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
23154 if(wtype==wtIWARPZAP)
23155 {
23156 zapout();
23157 }
23158 else if(wtype==wtIWARPWAVE)
23159 {
23160 //only draw Hero if he's not in a cave -DD
23161 wavyout(!cavewarp);
23162 }
23163 else if(wtype!=wtIWARP)
23164 {
23165 bool b2 = COOLSCROLL&&cavewarp;
23166 blackscr(30,b2?false:true);
23167 }
23168
23169 int32_t c = DMaps[currdmap].color;
23170 bool changedlevel = false;
23171 bool changeddmap = false;
23172 if(currdmap != wdmap)
23173 {
23174 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
23175 changeddmap = true;
23176 }
23177 if(dlevel != DMaps[wdmap].level)
23178 {
23179 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
23180 changedlevel = true;
23181 }
23182 dlevel = DMaps[wdmap].level;
23183 currdmap = wdmap;
23184 if(changeddmap)
23185 {
23186 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
23187 }
23188 if(changedlevel)
23189 {
23190 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
23191 }
23192 currmap = DMaps[currdmap].map;
23193 init_dmap();
23194 update_subscreens(wdmap);
23195
23196 ringcolor(false);
23197
23198 if(DMaps[currdmap].color != c)
23199 loadlvlpal(DMaps[currdmap].color);
23200
23201 homescr = currscr = wscr + DMaps[currdmap].xoff;
23202
23203 lightingInstant(); // Also sets naturaldark
23204
23205 loadscr(0,currdmap,currscr,-1,overlay);
23206
23207 x = tmpscr->warpreturnx[wrindex];
23208 y = tmpscr->warpreturny[wrindex];
23209
23210 if(didpit)
23211 {
23212 didpit=false;
23213 x=pitx;
23214 y=pity;
23215 }
23216
23217 type1 = combobuf[MAPCOMBO(x,y-16)].type;
23218 type2 = combobuf[MAPCOMBO(x,y)].type;
23219 type3 = combobuf[MAPCOMBO(x,y+16)].type;
23220
23221 if(x==0) dir=right;
23222
23223 if(x==240) dir=left;
23224
23225 if(y==0) dir=down;
23226
23227 if(y==160) dir=up;
23228
23229 markBmap(dir^1);
23230
23231 if(iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+8) && _walkflag(x,y+8,0,SWITCHBLOCK_STATE) && current_item(itype_flippers))
23232 {
23233 hopclk=0xFF;
23234 SetSwim();
23235 if (!IsSideSwim()) attackclk = charging = spins = 0;
23236 }
23237 else
23238 {
23239 action = none;
23240 FFCore.setHeroAction(none);
23241 }
23242 //preloaded freeform combos
23243 ffscript_engine(true);
23244
23245 putscr(scrollbuf,0,0,tmpscr);
23246 putscrdoors(scrollbuf,0,0,tmpscr);
23247
23248 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
23249 {
23250 reset_pal_cycling();
23251 putscr(scrollbuf,0,0,tmpscr);
23252 putscrdoors(scrollbuf,0,0,tmpscr);
23253 walkup(COOLSCROLL);
23254 }
23255 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
23256 {
23257 reset_pal_cycling();
23258 putscr(scrollbuf,0,0,tmpscr);
23259 putscrdoors(scrollbuf,0,0,tmpscr);
23260 walkdown2(COOLSCROLL);
23261 }
23262 else if(wtype==wtIWARPZAP)
23263 {
23264 zapin();
23265 }
23266 else if(wtype==wtIWARPWAVE)
23267 {
23268 wavyin();
23269 }
23270 else if(wtype==wtIWARPOPEN)
23271 {
23272 openscreen();
23273 }
23274 if(reposition_sword_postwarp)
23275 {
23276 weapon *swd=NULL;
23277 for(int32_t i=0; i<Lwpns.Count(); i++)
23278 {
23279 swd = (weapon*)Lwpns.spr(i);
23280
23281 if(swd->id == (attack==wSword ? wSword : wWand))
23282 {
23283 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23284 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23285 positionSword(swd,item_id);
23286 break;
23287 }
23288 }
23289 }
23290 show_subscreen_life=true;
23291 show_subscreen_numbers=true;
23292 playLevelMusic();
23293 currcset=DMaps[currdmap].color;
23294 dointro();
23295 set_respawn_point();
23296 trySideviewLadder();
23297 break;
23298 }
23299 else
23300 {
23301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(reposition_sword_postwarp)
23302 {
23303 weapon *swd=NULL;
23304 for(int32_t i=0; i<Lwpns.Count(); i++)
23305 {
23306 swd = (weapon*)Lwpns.spr(i);
23307
23308 if(swd->id == (attack==wSword ? wSword : wWand))
23309 {
23310 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23311 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23312 positionSword(swd,item_id);
23313 break;
23314 }
23315 }
23316 }
23317 37 didpit=false;
23318 37 update_subscreens();
23319 37 warp_sound = 0;
23320 37 is_warping = false;
23321 37 return false;
23322 }
23323 }
23324 default:
23325 didpit=false;
23326 update_subscreens();
23327 warp_sound = 0;
23328 is_warping = false;
23329 if(reposition_sword_postwarp)
23330 {
23331 weapon *swd=NULL;
23332 for(int32_t i=0; i<Lwpns.Count(); i++)
23333 {
23334 swd = (weapon*)Lwpns.spr(i);
23335
23336 if(swd->id == (attack==wSword ? wSword : wWand))
23337 {
23338 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23339 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23340 positionSword(swd,item_id);
23341 break;
23342 }
23343 }
23344 }
23345 return false;
23346 }
23347
23348
23349
23350 // Stop Hero from drowning!
23351
5/6
✓ Branch 0 taken 941 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 941 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 929 times.
953 if(action==drowning || action==lavadrowning || action==sidedrowning)
23352 {
23353 24 drownclk=0;
23354 24 drownclk=0;
23355 24 action=none; FFCore.setHeroAction(none);
23356 24 }
23357
23358 929 int32_t checkwater = iswaterex(MAPCOMBO(x,y+(bigHitbox?8:12)), currmap, currscr, -1, x,y+(bigHitbox?8:12));
23359 // But keep him swimming if he ought to be!
23360 // Unless the water is too high levelled, in which case... well, he'll drown on transition probably anyways. -Dimi
23361
9/12
✓ Branch 0 taken 938 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 15 times.
✓ Branch 10 taken 941 times.
✓ Branch 11 taken 6 times.
944 if(action!=rafting && checkwater && (_walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) || get_bit(quest_rules,qr_DROWN))
23362 //&& (current_item(itype_flippers) >= combobuf[checkwater].attribytes[0])
23363
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
15 && (action!=inwind))
23364 {
23365 6 hopclk=0xFF;
23366 6 SetSwim();
23367 6 }
23368
23369 947 newscr_clk=frame;
23370 947 activated_timed_warp=false;
23371 947 eat_buttons();
23372
23373
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 880 times.
947 if(wtype!=wtIWARP)
23374 880 attackclk=0;
23375
23376 947 didstuff=0;
23377 947 usecounts.clear();
23378 947 map_bkgsfx(true);
23379 947 loadside=dir^1;
23380 947 whistleclk=-1;
23381
23382
3/4
✓ Branch 0 taken 941 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 947 times.
✗ Branch 3 not taken.
947 if((z>0 || fakez>0) && isSideViewHero())
23383 {
23384 y-=z;
23385 y-=fakez;
23386 fakez=0;
23387 z=0;
23388 }
23389
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 921 times.
947 else if(!isSideViewHero())
23390 {
23391 921 fall=0;
23392 921 fakefall=0;
23393 921 }
23394
23395 // If warping between top-down and sideview screens,
23396 // fix enemies that are carried over by Full Screen Warp
23397 947 const bool tmpscr_is_sideview = isSideViewHero();
23398
23399
4/4
✓ Branch 0 taken 923 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 913 times.
✓ Branch 3 taken 10 times.
947 if(!wasSideview && tmpscr_is_sideview)
23400 {
23401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 for(int32_t i=0; i<guys.Count(); i++)
23402 {
23403 if(guys.spr(i)->z > 0 || guys.spr(i)->fakez > 0)
23404 {
23405 guys.spr(i)->y -= guys.spr(i)->z;
23406 guys.spr(i)->y -= guys.spr(i)->fakez;
23407 guys.spr(i)->z = 0;
23408 guys.spr(i)->fakez = 0;
23409 }
23410
23411 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
23412 guys.spr(i)->yofs += 2;
23413 }
23414 10 }
23415
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 919 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
937 else if(wasSideview && !tmpscr_is_sideview)
23416 {
23417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 for(int32_t i=0; i<guys.Count(); i++)
23418 {
23419 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
23420 guys.spr(i)->yofs -= 2;
23421 }
23422 8 }
23423
23424
6/6
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 343 times.
✓ Branch 2 taken 150 times.
✓ Branch 3 taken 454 times.
✓ Branch 4 taken 142 times.
✓ Branch 5 taken 8 times.
947 if((DMaps[currdmap].type&dmfCONTINUE) || (currdmap==0&&get_bit(quest_rules, qr_DMAP_0_CONTINUE_BUG)))
23425 {
23426
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 365 times.
485 if(dlevel)
23427 {
23428 int32_t wrx,wry;
23429
23430
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 93 times.
120 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
23431 {
23432 27 wrx=tmpscr->warpreturnx[0];
23433 27 wry=tmpscr->warpreturny[0];
23434 27 }
23435 else
23436 {
23437 93 wrx=tmpscr->warparrivalx;
23438 93 wry=tmpscr->warparrivaly;
23439 }
23440
23441
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
120 if((wtype == wtEXIT)
23442
5/10
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
120 || (((wtype == wtSCROLL) && !intradmap) && ((wrx>0 || wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))))
23443 {
23444
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
35 if(!(wtype==wtSCROLL)||!(get_bit(quest_rules,qr_NOSCROLLCONTINUE)))
23445 {
23446 35 game->set_continue_scrn(homescr);
23447 //Z_message("continue_scrn = %02X e/e\n",game->get_continue_scrn());
23448 35 }
23449 else if(currdmap != game->get_continue_dmap())
23450 {
23451 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
23452 }
23453 35 }
23454 else
23455 {
23456
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 3 times.
85 if(currdmap != game->get_continue_dmap())
23457 {
23458 3 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
23459 //Z_message("continue_scrn = %02X dlevel\n",game->get_continue_scrn());
23460 3 }
23461 }
23462 120 }
23463 else
23464 {
23465 365 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
23466 //Z_message("continue_scrn = %02X\n !dlevel\n",game->get_continue_scrn());
23467 }
23468
23469 485 game->set_continue_dmap(currdmap);
23470 485 lastentrance_dmap = currdmap;
23471 485 lastentrance = game->get_continue_scrn();
23472 //Z_message("continue_map = %d\n",game->get_continue_dmap());
23473 485 }
23474
23475
1/2
✓ Branch 0 taken 947 times.
✗ Branch 1 not taken.
947 if(tmpscr->flags4&fAUTOSAVE)
23476 {
23477 save_game(true,0);
23478 }
23479
23480
2/2
✓ Branch 0 taken 935 times.
✓ Branch 1 taken 12 times.
947 if(tmpscr->flags6&fCONTINUEHERE)
23481 {
23482 12 lastentrance_dmap = currdmap;
23483 12 lastentrance = homescr;
23484 12 }
23485
23486 947 update_subscreens();
23487 947 verifyBothWeapons();
23488
23489
2/2
✓ Branch 0 taken 609 times.
✓ Branch 1 taken 338 times.
947 if(wtype==wtCAVE)
23490 {
23491
2/2
✓ Branch 0 taken 241 times.
✓ Branch 1 taken 97 times.
338 if(DMaps[currdmap].flags&dmfGUYCAVES)
23492 482 Z_eventlog("Entered %s containing %s.\n",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar",
23493 241 (char *)moduledata.roomtype_names[tmpscr[1].room]);
23494 else
23495 97 Z_eventlog("Entered %s.",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar");
23496 338 }
23497 1218 else Z_eventlog("Warped to DMap %d: %s, screen %d, via %s.\n", currdmap, DMaps[currdmap].name,currscr,
23498
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 433 times.
1042 wtype==wtPASS ? "Passageway" :
23499
2/2
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 245 times.
678 wtype==wtEXIT ? "Entrance/Exit" :
23500
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 197 times.
245 wtype==wtSCROLL ? "Scrolling Warp" :
23501 197 wtype==wtWHISTLE ? "Whistle Warp" :
23502 "Insta-Warp");
23503
23504 947 eventlog_mapflags();
23505
1/2
✓ Branch 0 taken 947 times.
✗ Branch 1 not taken.
947 if(reposition_sword_postwarp)
23506 {
23507 weapon *swd=NULL;
23508 for(int32_t i=0; i<Lwpns.Count(); i++)
23509 {
23510 swd = (weapon*)Lwpns.spr(i);
23511
23512 if(swd->id == (attack==wSword ? wSword : wWand))
23513 {
23514 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23515 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23516 positionSword(swd,item_id);
23517 break;
23518 }
23519 }
23520 }
23521 947 FFCore.init_combo_doscript();
23522
4/4
✓ Branch 0 taken 460 times.
✓ Branch 1 taken 487 times.
✓ Branch 2 taken 454 times.
✓ Branch 3 taken 6 times.
947 if (!intradmap || get_bit(quest_rules, qr_WARPS_RESTART_DMAPSCRIPT))
23523 {
23524 941 FFScript::deallocateAllArrays(SCRIPT_DMAP, olddmap);
23525 941 FFCore.initZScriptDMapScripts();
23526 941 FFCore.initZScriptActiveSubscreenScript();
23527 941 }
23528 947 is_warping = false;
23529 947 return true;
23530 984 }
23531
23532 187 void HeroClass::exitcave()
23533 {
23534 187 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
23535 187 currscr=homescr;
23536 187 loadscr(0,currdmap,currscr,255,false); // bogus direction
23537 187 x = tmpscr->warpreturnx[0];
23538 187 y = tmpscr->warpreturny[0];
23539
23540
1/2
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
187 if(didpit)
23541 {
23542 didpit=false;
23543 x=pitx;
23544 y=pity;
23545 }
23546
23547
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 11 times.
187 if(x+y == 0)
23548 11 x = y = 80;
23549
23550 187 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
23551 187 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
23552 187 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
23553
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 170 times.
377 bool b = COOLSCROLL &&
23554
4/4
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 141 times.
170 ((type1==cCAVE) || (type1>=cCAVEB && type1<=cCAVED) ||
23555
4/4
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 141 times.
141 (type2==cCAVE) || (type2>=cCAVEB && type2<=cCAVED) ||
23556
4/4
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 123 times.
141 (type3==cCAVE2) || (type3>=cCAVE2B && type3<=cCAVE2D) ||
23557
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 123 times.
✓ Branch 3 taken 5 times.
123 (type2==cCAVE2) || (type2>=cCAVE2B && type2<=cCAVE2D));
23558 207 ALLOFF();
23559 207 blackscr(30,b?false:true);
23560 207 ringcolor(false);
23561 207 loadlvlpal(DMaps[currdmap].color);
23562 207 lighting(false, true);
23563 207 music_stop();
23564 207 kill_sfx();
23565 207 putscr(scrollbuf,0,0,tmpscr);
23566 207 putscrdoors(scrollbuf,0,0,tmpscr);
23567
23568
9/10
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 156 times.
✓ Branch 4 taken 161 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 156 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
207 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
23569 {
23570 56 walkup(COOLSCROLL);
23571 56 }
23572
9/10
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 138 times.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 138 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
161 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
23573 {
23574 18 walkdown2(COOLSCROLL);
23575 18 }
23576
23577 217 show_subscreen_life=true;
23578 217 show_subscreen_numbers=true;
23579 217 playLevelMusic();
23580 217 currcset=DMaps[currdmap].color;
23581 217 dointro();
23582 217 newscr_clk=frame;
23583 217 activated_timed_warp=false;
23584 217 dir=down;
23585 217 set_respawn_point();
23586 217 eat_buttons();
23587 217 didstuff=0;
23588 217 usecounts.clear();
23589 217 map_bkgsfx(true);
23590 217 loadside=dir^1;
23591 217 }
23592
23593
23594 3258 void HeroClass::stepforward(int32_t steps, bool adjust)
23595 {
23596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3258 times.
3258 if ( FFCore.nostepforward ) return;
23597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3258 times.
3258 if ( FFCore.temp_no_stepforward ) { FFCore.temp_no_stepforward = 0; return; }
23598 3258 zfix tx=x; //temp x
23599 3258 zfix ty=y; //temp y
23600 3258 zfix tstep(0); //temp single step distance
23601 3258 zfix s(0); //calculated step distance for all steps
23602 3258 z3step=2;
23603 3258 int32_t sh=shiftdir;
23604 3258 shiftdir=-1;
23605
23606
2/2
✓ Branch 0 taken 55601 times.
✓ Branch 1 taken 3258 times.
58859 for(int32_t i=steps; i>0; --i)
23607 {
23608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55601 times.
55601 if(diagonalMovement)
23609 {
23610 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23611 {
23612 tstep = 1.5;
23613 }
23614 else
23615 {
23616 tstep=z3step;
23617 z3step=(z3step%2)+1;
23618 }
23619 }
23620 else
23621 {
23622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55601 times.
55601 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT))
23623 {
23624 tstep = 1.5;
23625 }
23626 else
23627 {
23628
2/2
✓ Branch 0 taken 32626 times.
✓ Branch 1 taken 22975 times.
55601 tstep=lsteps[int32_t((dir<left)?ty:tx)&7];
23629
23630
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18128 times.
✓ Branch 2 taken 14498 times.
✓ Branch 3 taken 10205 times.
✓ Branch 4 taken 12770 times.
55601 switch(dir)
23631 {
23632 case up:
23633 18128 ty-=tstep;
23634 18128 break;
23635
23636 case down:
23637 14498 ty+=tstep;
23638 14498 break;
23639
23640 case left:
23641 10205 tx-=tstep;
23642 10205 break;
23643
23644 case right:
23645 12770 tx+=tstep;
23646 12770 break;
23647 }
23648 }
23649 }
23650
23651 55601 s+=tstep;
23652 55601 }
23653
23654 3258 z3step=2;
23655
23656 3258 x = x.getInt();
23657 3258 y = y.getInt();
23658
2/2
✓ Branch 0 taken 58788 times.
✓ Branch 1 taken 3258 times.
62046 while(s>=0)
23659 {
23660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58788 times.
58788 if(diagonalMovement)
23661 {
23662 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
23663 {
23664 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23665 {
23666 walkable = false;
23667 shiftdir = -1;
23668 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
23669 switch(tdir)
23670 {
23671 case left:
23672 --x;
23673 break;
23674 case right:
23675 ++x;
23676 break;
23677 case up:
23678 --y;
23679 break;
23680 case down:
23681 ++y;
23682 break;
23683 }
23684 }
23685 else
23686 {
23687 walkable=false;
23688 shiftdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
23689 move(dir, 150);
23690 }
23691 }
23692 else
23693 {
23694 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23695 {
23696 s-=1.5;
23697 }
23698 else
23699 {
23700 s-=z3step;
23701 }
23702 walkable=true;
23703 move(dir, 150);
23704 }
23705
23706 shiftdir=-1;
23707 }
23708 else
23709 {
23710
3/6
✓ Branch 0 taken 34562 times.
✓ Branch 1 taken 24226 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 58788 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58788 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
23711 {
23712 walkable=false;
23713 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
23714 switch(tdir)
23715 {
23716 case left:
23717 --x;
23718 break;
23719 case right:
23720 ++x;
23721 break;
23722 case up:
23723 --y;
23724 break;
23725 case down:
23726 ++y;
23727 break;
23728 }
23729 }
23730 else
23731 {
23732
2/4
✓ Branch 0 taken 58788 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58788 times.
58788 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23733 {
23734 s-=1.5;
23735 }
23736
2/2
✓ Branch 0 taken 34562 times.
✓ Branch 1 taken 24226 times.
58788 else if(dir<left)
23737 {
23738 34562 s-=lsteps[y.getInt()&7];
23739 34562 }
23740 else
23741 {
23742 24226 s-=lsteps[x.getInt()&7];
23743 }
23744
23745 58788 move(dir, 150);
23746 }
23747 }
23748
23749
2/2
✓ Branch 0 taken 55530 times.
✓ Branch 1 taken 3258 times.
58788 if(s<0)
23750 {
23751 // Not quite sure how this is actually supposed to work.
23752 // There have to be two cases for each direction or Hero
23753 // either walks too far onto the screen or may get stuck
23754 // going through walk-through walls.
23755
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1246 times.
✓ Branch 2 taken 760 times.
✓ Branch 3 taken 542 times.
✓ Branch 4 taken 710 times.
3258 switch(dir)
23756 {
23757 case up:
23758
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 1176 times.
1246 if(y<8) // Leaving the screen
23759 70 y+=s;
23760 else // Entering the screen
23761 1176 y-=s;
23762
23763 1246 break;
23764
23765 case down:
23766
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 696 times.
760 if(y>152)
23767 64 y-=s;
23768 else
23769 696 y+=s;
23770
23771 760 break;
23772
23773 case left:
23774
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 493 times.
542 if(x<8)
23775 49 x+=s;
23776 else
23777 493 x-=s;
23778
23779 542 break;
23780
23781 case right:
23782
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 652 times.
710 if(x>=232)
23783 58 x-=s;
23784 else
23785 652 x+=s;
23786
23787 710 break;
23788 }
23789 3258 }
23790
23791
23792 58788 draw_screen(tmpscr);
23793
1/2
✓ Branch 0 taken 58788 times.
✗ Branch 1 not taken.
58788 if (canSideviewLadder()) setOnSideviewLadder(true);
23794 58788 advanceframe(true);
23795
23796
1/2
✓ Branch 0 taken 58788 times.
✗ Branch 1 not taken.
58788 if(Quit)
23797 return;
23798 }
23799
4/4
✓ Branch 0 taken 2548 times.
✓ Branch 1 taken 710 times.
✓ Branch 2 taken 760 times.
✓ Branch 3 taken 1788 times.
3258 if(dir==right||dir==down)
23800 {
23801 1470 x=int32_t(x);
23802 1470 y=int32_t(y);
23803 1470 }
23804 else
23805 {
23806 1788 x = x.getInt();
23807 1788 y = y.getInt();
23808 }
23809 3258 set_respawn_point();
23810 3258 draw_screen(tmpscr);
23811 3258 eat_buttons();
23812 3258 shiftdir=sh;
23813 3258 }
23814
23815 142 void HeroClass::walkdown(bool opening) //entering cave
23816 {
23817
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 113 times.
142 if(opening)
23818 {
23819 113 close_black_opening(x+8, y+8+playing_field_offset, false);
23820 113 }
23821
23822 142 hclk=0;
23823 142 stop_item_sfx(itype_brang);
23824 142 sfx(WAV_STAIRS,pan(x.getInt()));
23825 142 clk=0;
23826 // int32_t cmby=(y.getInt()&0xF0)+16;
23827 // Fix Hero's position to the grid
23828 142 y=y.getInt()&0xF0;
23829 142 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
23830 142 attack=wNone;
23831 142 attackid=-1;
23832 142 reset_swordcharge();
23833 142 climb_cover_x=x.getInt()&0xF0;
23834 142 climb_cover_y=(y.getInt()&0xF0)+16;
23835
23836 142 guys.clear();
23837 142 chainlinks.clear();
23838 142 Lwpns.clear();
23839 142 Ewpns.clear();
23840 142 items.clear();
23841
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 9088 times.
9230 for(int32_t i=0; i<64; i++)
23842 {
23843 9088 herostep();
23844
23845
2/4
✓ Branch 0 taken 9088 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9088 times.
9088 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
23846 hero_count=(hero_count+1)%16;
23847
23848
2/2
✓ Branch 0 taken 6816 times.
✓ Branch 1 taken 2272 times.
9088 if((i&3)==3)
23849 2272 ++y;
23850
23851 9088 draw_screen(tmpscr);
23852 9088 advanceframe(true);
23853
23854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9088 times.
9088 if(Quit)
23855 break;
23856 9088 }
23857
23858 142 action=none; FFCore.setHeroAction(none);
23859 142 }
23860
23861 21 void HeroClass::walkdown2(bool opening) //exiting cave 2
23862 {
23863 21 int32_t type = combobuf[MAPCOMBO(x,y)].type;
23864
23865
2/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
21 if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
23866 y-=16;
23867
23868 21 dir=down;
23869 // Fix Hero's position to the grid
23870 21 y=y.getInt()&0xF0;
23871 21 z=fakez=fall=fakefall=0;
23872
23873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(opening)
23874 {
23875 21 open_black_opening(x+8, y+8+playing_field_offset+16, false);
23876 21 }
23877
23878 21 hclk=0;
23879 21 stop_item_sfx(itype_brang);
23880 21 sfx(WAV_STAIRS,pan(x.getInt()));
23881 21 clk=0;
23882 // int32_t cmby=y.getInt()&0xF0;
23883 21 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
23884 21 attack=wNone;
23885 21 attackid=-1;
23886 21 reset_swordcharge();
23887 21 climb_cover_x=x.getInt()&0xF0;
23888 21 climb_cover_y=y.getInt()&0xF0;
23889
23890 21 guys.clear();
23891 21 chainlinks.clear();
23892 21 Lwpns.clear();
23893 21 Ewpns.clear();
23894 21 items.clear();
23895
23896
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1344 times.
1365 for(int32_t i=0; i<64; i++)
23897 {
23898 1344 herostep();
23899
23900
2/4
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1344 times.
1344 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
23901 hero_count=(hero_count+1)%16;
23902
23903
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 336 times.
1344 if((i&3)==3)
23904 336 ++y;
23905
23906 1344 draw_screen(tmpscr);
23907 1344 advanceframe(true);
23908
23909
1/2
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
1344 if(Quit)
23910 break;
23911 1344 }
23912
23913 21 action=none; FFCore.setHeroAction(none);
23914 21 }
23915
23916 111 void HeroClass::walkup(bool opening) //exiting cave
23917 {
23918 111 int32_t type = combobuf[MAPCOMBO(x,y)].type;
23919
23920
4/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 107 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
111 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
23921 y+=16;
23922
23923 // Fix Hero's position to the grid
23924 111 y=y.getInt()&0xF0;
23925 111 z=fakez=fall=fakefall=0;
23926
23927
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 89 times.
111 if(opening)
23928 {
23929 89 open_black_opening(x+8, y+8+playing_field_offset-16, false);
23930 89 }
23931
23932 111 hclk=0;
23933 111 stop_item_sfx(itype_brang);
23934 111 sfx(WAV_STAIRS,pan(x.getInt()));
23935 111 dir=down;
23936 111 clk=0;
23937 // int32_t cmby=y.getInt()&0xF0;
23938 111 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
23939 111 attack=wNone;
23940 111 attackid=-1;
23941 111 reset_swordcharge();
23942 111 climb_cover_x=x.getInt()&0xF0;
23943 111 climb_cover_y=y.getInt()&0xF0;
23944
23945 111 guys.clear();
23946 111 chainlinks.clear();
23947 111 Lwpns.clear();
23948 111 Ewpns.clear();
23949 111 items.clear();
23950
23951
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 7104 times.
7215 for(int32_t i=0; i<64; i++)
23952 {
23953 7104 herostep();
23954
23955
2/4
✓ Branch 0 taken 7104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7104 times.
7104 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
23956 hero_count=(hero_count+1)%16;
23957
23958
2/2
✓ Branch 0 taken 5328 times.
✓ Branch 1 taken 1776 times.
7104 if((i&3)==0)
23959 1776 --y;
23960
23961 7104 draw_screen(tmpscr);
23962 7104 advanceframe(true);
23963
23964
1/2
✓ Branch 0 taken 7104 times.
✗ Branch 1 not taken.
7104 if(Quit)
23965 break;
23966 7104 }
23967 111 map_bkgsfx(true);
23968 111 loadside=dir^1;
23969 111 action=none; FFCore.setHeroAction(none);
23970 111 }
23971
23972 27 void HeroClass::walkup2(bool opening) //entering cave2
23973 {
23974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(opening)
23975 {
23976 27 close_black_opening(x+8, y+8+playing_field_offset, false);
23977 27 }
23978
23979 27 hclk=0;
23980 27 stop_item_sfx(itype_brang);
23981 27 sfx(WAV_STAIRS,pan(x.getInt()));
23982 27 dir=up;
23983 27 clk=0;
23984 // int32_t cmby=y.getInt()&0xF0;
23985 27 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
23986 27 attack=wNone;
23987 27 attackid=-1;
23988 27 reset_swordcharge();
23989 27 climb_cover_x=x.getInt()&0xF0;
23990 27 climb_cover_y=(y.getInt()&0xF0)-16;
23991
23992 27 guys.clear();
23993 27 chainlinks.clear();
23994 27 Lwpns.clear();
23995 27 Ewpns.clear();
23996 27 items.clear();
23997
23998
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1728 times.
1755 for(int32_t i=0; i<64; i++)
23999 {
24000 1728 herostep();
24001
24002
2/4
✓ Branch 0 taken 1728 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1728 times.
1728 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
24003 hero_count=(hero_count+1)%16;
24004
24005
2/2
✓ Branch 0 taken 1296 times.
✓ Branch 1 taken 432 times.
1728 if((i&3)==0)
24006 432 --y;
24007
24008 1728 draw_screen(tmpscr);
24009 1728 advanceframe(true);
24010
24011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1728 times.
1728 if(Quit)
24012 break;
24013 1728 }
24014 27 map_bkgsfx(true);
24015 27 loadside=dir^1;
24016 27 action=none; FFCore.setHeroAction(none);
24017 27 }
24018
24019 253 void HeroClass::stepout() // Step out of item cellars and passageways
24020 {
24021 253 int32_t sc = specialcave; // This gets erased by ALLOFF()
24022 253 ALLOFF();
24023 253 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
24024 253 map_bkgsfx(false);
24025 253 kill_enemy_sfx();
24026 253 draw_screen(tmpscr,false);
24027 253 fade(sc>=GUYCAVE?10:11,true,false);
24028 253 blackscr(30,true);
24029 253 ringcolor(false);
24030
24031
4/4
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 169 times.
✓ Branch 2 taken 124 times.
✓ Branch 3 taken 129 times.
253 if(sc==PASSAGEWAY && abs(x-warpx)>16) // How did Hero leave the passageway?
24032 {
24033 129 currdmap=stepoutdmap;
24034 129 currmap=DMaps[currdmap].map;
24035 129 dlevel=DMaps[currdmap].level;
24036
24037 //we might have just left a passage, so be sure to update the CSet record -DD
24038 129 currcset=DMaps[currdmap].color;
24039
24040 129 init_dmap();
24041 129 homescr=stepoutscr;
24042 129 }
24043
24044 253 currscr=homescr;
24045 253 loadscr(0,currdmap,currscr,255,false); // bogus direction
24046 253 draw_screen(tmpscr,false);
24047
24048
3/4
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 3 times.
253 if(get_bit(quest_rules, qr_NEW_DARKROOM) || !(tmpscr->flags&fDARK))
24049 {
24050 250 darkroom = naturaldark = false;
24051 250 fade(DMaps[currdmap].color,true,true);
24052 250 }
24053 else
24054 {
24055 3 darkroom = naturaldark = true;
24056
24057
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(get_bit(quest_rules,qr_FADE))
24058 {
24059 1 interpolatedfade();
24060 1 }
24061 else
24062 {
24063 2 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
24064 }
24065 3 byte *si = colordata + CSET(DMaps[currdmap].color*pdLEVEL+poLEVEL)*3;
24066 3 si+=3*48;
24067
24068
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 3 times.
51 for(int32_t i=0; i<16; i++)
24069 {
24070 48 RAMpal[CSET(9)+i] = _RGB(si);
24071 48 tempgreypal[CSET(9)+i] = _RGB(si); //preserve monochrome
24072 48 si+=3;
24073 48 }
24074 }
24075
24076 253 x = tmpscr->warpreturnx[stepoutwr];
24077 253 y = tmpscr->warpreturny[stepoutwr];
24078
24079
1/2
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
253 if(didpit)
24080 {
24081 didpit=false;
24082 x=pitx;
24083 y=pity;
24084 }
24085
24086
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 247 times.
253 if(x+y == 0)
24087 6 x = y = 80;
24088
24089 253 dir=down;
24090
24091 253 set_respawn_point();
24092
24093 // Let's use the 'exit cave' animation if we entered this cellar via a cave combo.
24094 253 int32_t type = combobuf[MAPCOMBO(tmpscr->warpreturnx[stepoutwr],tmpscr->warpreturny[stepoutwr])].type;
24095
24096
4/6
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 248 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
253 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
24097 {
24098 walkup(false);
24099 }
24100
4/6
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 248 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
253 else if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
24101 {
24102 walkdown2(false);
24103 }
24104
24105 253 newscr_clk=frame;
24106 253 activated_timed_warp=false;
24107 253 didstuff=0;
24108 253 usecounts.clear();
24109 253 eat_buttons();
24110 253 markBmap(-1);
24111 253 map_bkgsfx(true);
24112
24113
2/2
✓ Branch 0 taken 226 times.
✓ Branch 1 taken 27 times.
253 if(!get_bit(quest_rules, qr_CAVEEXITNOSTOPMUSIC))
24114 {
24115 27 music_stop();
24116 27 playLevelMusic();
24117 27 }
24118
1/2
✓ Branch 0 taken 226 times.
✗ Branch 1 not taken.
226 else if(get_bit(quest_rules,qr_SCREEN80_OWN_MUSIC))
24119 {
24120 playLevelMusic();
24121 }
24122
24123 253 loadside=dir^1;
24124 253 }
24125
24126 5595 bool HeroClass::nextcombo_wf(int32_t d2)
24127 {
24128
6/8
✓ Branch 0 taken 5544 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 5386 times.
✓ Branch 3 taken 158 times.
✓ Branch 4 taken 5386 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 158 times.
✗ Branch 7 not taken.
5595 if(toogam || (action!=swimming && !IsSideSwim() && action != swimhit) || hopclk==0) //!DIMITODO: ...does swimming just let you ignore smart scrolling entirely!?
24129 5595 return false;
24130
24131 // assumes Hero is about to scroll screens
24132
24133 int32_t ns = nextscr(d2);
24134
24135 if(ns==0xFFFF)
24136 return false;
24137
24138 // want actual screen index, not game->maps[] index
24139 ns = (ns&127) + (ns>>7)*MAPSCRS;
24140
24141 int32_t cx = x;
24142 int32_t cy = y;
24143
24144 switch(d2)
24145 {
24146 case up:
24147 cy=160;
24148 break;
24149
24150 case down:
24151 cy=0;
24152 break;
24153
24154 case left:
24155 cx=240;
24156 break;
24157
24158 case right:
24159 cx=0;
24160 break;
24161 }
24162
24163 // check lower half of combo
24164 cy += 8;
24165
24166 // from MAPCOMBO()
24167 int32_t cmb = (cy&0xF0)+(cx>>4);
24168
24169 if(cmb>175)
24170 return true;
24171
24172 newcombo c = combobuf[TheMaps[ns].data[cmb]];
24173 bool dried = iswater_type(c.type) && DRIEDLAKE;
24174 bool swim = iswater_type(c.type) && (current_item(itype_flippers)) && !dried;
24175 int32_t b=1;
24176
24177 if(cx&8) b<<=2;
24178
24179 if(cy&8) b<<=1;
24180
24181 if((c.walk&b) && !dried && !swim)
24182 return true;
24183
24184 // next block (i.e. cnt==2)
24185 if(!(cx&8))
24186 {
24187 b<<=2;
24188 }
24189 else
24190 {
24191 c = combobuf[TheMaps[ns].data[++cmb]];
24192 dried = iswater_type(c.type) && DRIEDLAKE;
24193 swim = iswater_type(c.type) && (current_item(itype_flippers)) && !dried;
24194 b=1;
24195
24196 if(cy&8)
24197 {
24198 b<<=1;
24199 }
24200 }
24201
24202 return (c.walk&b) ? !dried && !swim : false;
24203 5595 }
24204
24205 bool HeroClass::nextcombo_solid(int32_t d2)
24206 {
24207 if(toogam || currscr>=128)
24208 return false;
24209
24210 // assumes Hero is about to scroll screens
24211
24212 int32_t ns = nextscr(d2);
24213
24214 if(ns==0xFFFF)
24215 return false;
24216
24217 // want actual screen index, not game->maps[] index
24218 ns = (ns&127) + (ns>>7)*MAPSCRS;
24219 int32_t screen = (ns%MAPSCRS);
24220 int32_t map = (ns - screen) / MAPSCRS;
24221
24222 int32_t cx = x;
24223 int32_t cy = y;
24224
24225 switch(d2)
24226 {
24227 case up:
24228 cy=160;
24229 break;
24230
24231 case down:
24232 cy=0;
24233 break;
24234
24235 case left:
24236 cx=240;
24237 break;
24238
24239 case right:
24240 cx=0;
24241 break;
24242 }
24243
24244 if(d2==up) cy += 8;
24245
24246 if(d2==left||d2==right) cy+=bigHitbox?0:8;
24247
24248 int32_t initcx = cx;
24249 int32_t initcy = cy;
24250 // from MAPCOMBO()
24251
24252 for(int32_t i=0; i<=((bigHitbox&&!(d2==up||d2==down))?((initcy&7)?2:1):((initcy&7)?1:0)) && cy < 176; cy+=(cy%2)?7:8,i++)
24253 {
24254 cx = initcx;
24255 for(int32_t k=0; k<=(get_bit(quest_rules, qr_SMARTER_SMART_SCROLL)?((initcx&7)?2:1):0) && cx < 256; cx+=(cx%2)?7:8,k++)
24256 {
24257 int32_t cmb = (cy&0xF0)+(cx>>4);
24258
24259 if(cmb>175)
24260 {
24261 return true;
24262 }
24263
24264 newcombo const& c = combobuf[MAPCOMBO3(map, screen, -1,cx,cy, get_bit(quest_rules, qr_SMARTER_SMART_SCROLL))];
24265
24266 int32_t b=1;
24267
24268 if(cx&8) b<<=2;
24269
24270 if(cy&8) b<<=1;
24271
24272 //bool bridgedetected = false;
24273
24274 int32_t walk = c.walk;
24275 if (get_bit(quest_rules, qr_SMARTER_SMART_SCROLL))
24276 {
24277 for (int32_t m = 0; m <= 1; m++)
24278 {
24279 newcombo const& cmb = combobuf[MAPCOMBO3(map, screen, m,cx,cy, true)];
24280 if (cmb.type == cBRIDGE)
24281 {
24282 if (!get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
24283 {
24284 int efflag = (cmb.walk & 0xF0)>>4;
24285 int newsolid = (cmb.walk & 0xF);
24286 walk = ((newsolid | walk) & (~efflag)) | (newsolid & efflag);
24287 }
24288 else walk &= cmb.walk;
24289 }
24290 else walk |= cmb.walk;
24291 }
24292 }
24293 /*
24294 if (bridgedetected)
24295 {
24296 continue;
24297 }*/
24298
24299 //bool swim = iswater_type(c.type) && (current_item(itype_flippers) || action==rafting);
24300 bool swim = iswaterex(MAPCOMBO3(map, screen, -1,cx,cy, get_bit(quest_rules, qr_SMARTER_SMART_SCROLL)), map, screen, -1, cx, cy, true, false, true) && (current_item(itype_flippers) || action==rafting);
24301
24302 if((walk&b) && !swim)
24303 {
24304 return true;
24305 }
24306 }
24307
24308 /*
24309 #if 0
24310
24311 //
24312 // next block (i.e. cnt==2)
24313 if(!(cx&8))
24314 {
24315 b<<=2;
24316 }
24317 else
24318 {
24319 c = combobuf[TheMaps[ns].data[++cmb]];
24320 dried = iswater_type(c.type) && DRIEDLAKE;
24321 //swim = iswater_type(c.type) && (current_item(itype_flippers));
24322 b=1;
24323
24324 if(cy&8)
24325 {
24326 b<<=1;
24327 }
24328 }
24329
24330 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
24331
24332 if((c.walk&b) && !dried && !swim)
24333 {
24334 return true;
24335 }
24336
24337 cx+=8;
24338
24339 if(cx&7)
24340 {
24341 if(!(cx&8))
24342 {
24343 b<<=2;
24344 }
24345 else
24346 {
24347 c = combobuf[TheMaps[ns].data[++cmb]];
24348 dried = iswater_type(c.type) && DRIEDLAKE;
24349 //swim = iswaterex(cmb, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
24350 b=1;
24351
24352 if(cy&8)
24353 {
24354 b<<=1;
24355 }
24356 }
24357
24358 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
24359
24360 if((c.walk&b) && !dried && !swim)
24361 return true;
24362 }
24363
24364 #endif
24365 */
24366 }
24367
24368 return false;
24369 }
24370
24371 3394924 void HeroClass::checkscroll()
24372 {
24373 //DO NOT scroll if Hero is vibrating due to Farore's Wind effect -DD
24374
2/4
✓ Branch 0 taken 3394924 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3394924 times.
✗ Branch 3 not taken.
3394924 if(action == casting||action==sideswimcasting)
24375 return;
24376
24377
2/2
✓ Branch 0 taken 3381518 times.
✓ Branch 1 taken 13406 times.
3394924 if(toogam)
24378 {
24379
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 13398 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
13406 if(x<0 && (currscr&15)==0) x=0;
24380
24381
3/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 13386 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
13406 if(y<0 && currscr<16) y=0;
24382
24383
3/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 13391 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
13406 if(x>240 && (currscr&15)==15) x=240;
24384
24385
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 13398 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
13406 if(y>160 && currscr>=112) y=160;
24386 13406 }
24387
24388
2/2
✓ Branch 0 taken 3393116 times.
✓ Branch 1 taken 1808 times.
3394924 if(y<0)
24389 {
24390 1808 bool doit=true;
24391 1808 y=0;
24392
24393
3/6
✓ Branch 0 taken 1808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1808 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1808 times.
1808 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24394 doit = false;
24395
24396
1/2
✓ Branch 0 taken 1808 times.
✗ Branch 1 not taken.
1808 if(nextcombo_wf(up))
24397 doit=false;
24398
24399
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 1808 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1808 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling && !(tmpscr->flags2&wfUP))
24400 {
24401 if(nextcombo_solid(up))
24402 doit=false;
24403 }
24404
24405
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1808 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1808 if(doit || action==inwind)
24406 {
24407
2/2
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 1555 times.
1808 if(currscr>=128)
24408 {
24409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 253 times.
253 if(specialcave >= GUYCAVE)
24410 exitcave();
24411 253 else stepout();
24412 253 }
24413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1555 times.
1555 else if(action==inwind)
24414 {
24415 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24416 {
24417 action=none; FFCore.setHeroAction(none);
24418 restart_level();
24419 }
24420 else
24421 {
24422 dowarp(2,up);
24423 }
24424 }
24425
3/6
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 1521 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1555 else if(tmpscr->flags2&wfUP && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24426 {
24427 34 sdir=up;
24428 34 dowarp(1,(tmpscr->sidewarpindex)&3);
24429 34 }
24430
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 1461 times.
1521 else if(!edge_of_dmap(up))
24431 {
24432 1461 scrolling_map = currmap;
24433 1461 scrollscr(up);
24434
24435
1/2
✓ Branch 0 taken 1461 times.
✗ Branch 1 not taken.
1461 if(tmpscr->flags4&fAUTOSAVE)
24436 {
24437 save_game(true,0);
24438 }
24439
24440
2/2
✓ Branch 0 taken 1457 times.
✓ Branch 1 taken 4 times.
1461 if(tmpscr->flags6&fCONTINUEHERE)
24441 {
24442 4 lastentrance_dmap = currdmap;
24443 4 lastentrance = homescr;
24444 4 }
24445 1461 }
24446 1808 }
24447 1808 }
24448
24449
2/2
✓ Branch 0 taken 3393849 times.
✓ Branch 1 taken 1075 times.
3394924 if(y>160)
24450 {
24451 1075 bool doit=true;
24452 1075 y=160;
24453
24454
4/6
✓ Branch 0 taken 1074 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1074 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1075 times.
1075 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24455 doit = false;
24456
24457
1/2
✓ Branch 0 taken 1075 times.
✗ Branch 1 not taken.
1075 if(nextcombo_wf(down))
24458 doit=false;
24459
24460
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 1075 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1075 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfDOWN))
24461 {
24462 if(nextcombo_solid(down))
24463 doit=false;
24464 }
24465
24466
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1075 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1075 if(doit || action==inwind)
24467 {
24468
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 913 times.
1075 if(currscr>=128)
24469 {
24470
1/2
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
162 if(specialcave >= GUYCAVE)
24471 162 exitcave();
24472 else stepout();
24473 162 }
24474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 913 times.
913 else if(action==inwind)
24475 {
24476 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24477 {
24478 action=none; FFCore.setHeroAction(none);
24479 restart_level();
24480 }
24481 else
24482 {
24483 dowarp(2,down);
24484 }
24485 }
24486
3/6
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 866 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
913 else if(tmpscr->flags2&wfDOWN && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24487 {
24488 47 sdir=down;
24489 47 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
24490 47 }
24491
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 861 times.
866 else if(!edge_of_dmap(down))
24492 {
24493 861 scrolling_map = currmap;
24494 861 scrollscr(down);
24495
24496
1/2
✓ Branch 0 taken 861 times.
✗ Branch 1 not taken.
861 if(tmpscr->flags4&fAUTOSAVE)
24497 {
24498 save_game(true,0);
24499 }
24500
24501
2/2
✓ Branch 0 taken 859 times.
✓ Branch 1 taken 2 times.
861 if(tmpscr->flags6&fCONTINUEHERE)
24502 {
24503 2 lastentrance_dmap = currdmap;
24504 2 lastentrance = homescr;
24505 2 }
24506 861 }
24507 1075 }
24508 1075 }
24509
24510
2/2
✓ Branch 0 taken 3393666 times.
✓ Branch 1 taken 1258 times.
3394924 if(x<0)
24511 {
24512 1258 bool doit=true;
24513 1258 x=0;
24514
24515
3/6
✓ Branch 0 taken 1258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1258 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1258 times.
1258 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24516 doit = false;
24517
24518
1/2
✓ Branch 0 taken 1258 times.
✗ Branch 1 not taken.
1258 if(nextcombo_wf(left))
24519 doit=false;
24520
24521
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 1258 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1258 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfLEFT))
24522 {
24523 if(nextcombo_solid(left))
24524 doit=false;
24525 }
24526
24527
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1258 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1258 if(doit || action==inwind)
24528 {
24529
1/2
✓ Branch 0 taken 1258 times.
✗ Branch 1 not taken.
1258 if(currscr>=128)
24530 {
24531 if(specialcave >= GUYCAVE)
24532 exitcave();
24533 else stepout();
24534 }
24535
24536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1258 times.
1258 if(action==inwind)
24537 {
24538 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24539 {
24540 action=none; FFCore.setHeroAction(none);
24541 restart_level();
24542 }
24543 else
24544 {
24545 dowarp(2,left);
24546 }
24547 }
24548
3/6
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1231 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1258 else if(tmpscr->flags2&wfLEFT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24549 {
24550 27 sdir=left;
24551 27 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
24552 27 }
24553
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 1142 times.
1231 else if(!edge_of_dmap(left))
24554 {
24555 1142 scrolling_map = currmap;
24556 1142 scrollscr(left);
24557
24558
1/2
✓ Branch 0 taken 1142 times.
✗ Branch 1 not taken.
1142 if(tmpscr->flags4&fAUTOSAVE)
24559 {
24560 save_game(true,0);
24561 }
24562
24563
2/2
✓ Branch 0 taken 1134 times.
✓ Branch 1 taken 8 times.
1142 if(tmpscr->flags6&fCONTINUEHERE)
24564 {
24565 8 lastentrance_dmap = currdmap;
24566 8 lastentrance = homescr;
24567 8 }
24568 1142 }
24569 1258 }
24570 1258 }
24571
24572
2/2
✓ Branch 0 taken 3393529 times.
✓ Branch 1 taken 1395 times.
3394924 if(x>240)
24573 {
24574 1395 bool doit=true;
24575 1395 x=240;
24576
24577
3/6
✓ Branch 0 taken 1395 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1395 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1395 times.
1395 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24578 doit = false;
24579
24580
1/2
✓ Branch 0 taken 1395 times.
✗ Branch 1 not taken.
1395 if(nextcombo_wf(right))
24581 doit=false;
24582
24583
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 1395 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1395 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfRIGHT))
24584 {
24585 if(nextcombo_solid(right))
24586 doit=false;
24587 }
24588
24589
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1395 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1395 if(doit || action==inwind)
24590 {
24591
1/2
✓ Branch 0 taken 1395 times.
✗ Branch 1 not taken.
1395 if(currscr>=128)
24592 {
24593 if(specialcave >= GUYCAVE)
24594 exitcave();
24595 else stepout();
24596 }
24597
24598
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1374 times.
1395 if(action==inwind)
24599 {
24600
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 20 times.
21 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24601 {
24602 1 action=none; FFCore.setHeroAction(none);
24603 1 restart_level();
24604 1 }
24605 else
24606 {
24607 20 dowarp(2,right);
24608 }
24609 21 }
24610
3/6
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 1333 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1374 else if(tmpscr->flags2&wfRIGHT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24611 {
24612 41 sdir=right;
24613 41 dowarp(1,(tmpscr->sidewarpindex>>6)&3);
24614 41 }
24615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1333 times.
1333 else if(!edge_of_dmap(right))
24616 {
24617 1333 scrolling_map = currmap;
24618 1333 scrollscr(right);
24619
24620
1/2
✓ Branch 0 taken 1333 times.
✗ Branch 1 not taken.
1333 if(tmpscr->flags4&fAUTOSAVE)
24621 {
24622 save_game(true,0);
24623 }
24624
24625
2/2
✓ Branch 0 taken 1323 times.
✓ Branch 1 taken 10 times.
1333 if(tmpscr->flags6&fCONTINUEHERE)
24626 {
24627 10 lastentrance_dmap = currdmap;
24628 10 lastentrance = homescr;
24629 10 }
24630 1333 }
24631 1395 }
24632 1395 }
24633 3394924 }
24634
24635 // assumes current direction is in lastdir[3]
24636 // compares directions with scr->path and scr->exitdir
24637 14498 bool HeroClass::checkmaze(mapscr *scr, bool sound)
24638 {
24639
2/2
✓ Branch 0 taken 14338 times.
✓ Branch 1 taken 160 times.
14498 if(!(scr->flags&fMAZE))
24640 14338 return true;
24641
24642
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 136 times.
160 if(lastdir[3]==scr->exitdir)
24643 24 return true;
24644
24645
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 20 times.
225 for(int32_t i=0; i<4; i++)
24646
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 116 times.
205 if(lastdir[i]!=scr->path[i])
24647 116 return false;
24648
24649
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 10 times.
20 if(sound)
24650 10 sfx(scr->secretsfx);
24651
24652 20 return true;
24653 14498 }
24654
24655 9701 bool HeroClass::edge_of_dmap(int32_t side)
24656 {
24657
2/2
✓ Branch 0 taken 9632 times.
✓ Branch 1 taken 69 times.
9701 if(checkmaze(tmpscr,false)==false)
24658 69 return false;
24659
24660 // needs fixin'
24661 // should check dmap style
24662
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2931 times.
✓ Branch 2 taken 1711 times.
✓ Branch 3 taken 2340 times.
✓ Branch 4 taken 2650 times.
9632 switch(side)
24663 {
24664 case up:
24665 2931 return currscr<16;
24666
24667 case down:
24668 1711 return currscr>=112;
24669
24670 case left:
24671
2/2
✓ Branch 0 taken 2251 times.
✓ Branch 1 taken 89 times.
2340 if((currscr&15)==0)
24672 89 return true;
24673
24674
2/2
✓ Branch 0 taken 1486 times.
✓ Branch 1 taken 765 times.
2251 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
24675 // if(dlevel)
24676 1486 return (((currscr&15)-DMaps[currdmap].xoff)<=0);
24677
24678 765 break;
24679
24680 case right:
24681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2650 times.
2650 if((currscr&15)==15)
24682 return true;
24683
24684
2/2
✓ Branch 0 taken 1807 times.
✓ Branch 1 taken 843 times.
2650 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
24685 // if(dlevel)
24686 1807 return (((currscr&15)-DMaps[currdmap].xoff)>=7);
24687
24688 843 break;
24689 }
24690
24691 1608 return false;
24692 9701 }
24693
24694 87 bool HeroClass::lookaheadraftflag(int32_t d2)
24695 {
24696 // Helper for scrollscr that gets next combo on next screen.
24697 // Can use destscr for scrolling warps,
24698 // but assumes currmap is correct.
24699
24700 87 int32_t cx = x;
24701 87 int32_t cy = y + 8;
24702
24703 87 bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24704 87 bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24705 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
24706 //Applying this here, too. -Z
24707
24708
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 25 times.
87 switch(d2)
24709 {
24710 case up:
24711 24 cy=160;
24712 24 break;
24713
24714 case down:
24715 16 cy=0;
24716 16 break;
24717
24718 case left:
24719 22 cx=240;
24720 22 break;
24721
24722 case right:
24723 25 cx=0;
24724 25 break;
24725 }
24726
24727 87 int32_t combo = (cy&0xF0)+(cx>>4);
24728
24729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(combo>175)
24730 return 0;
24731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 return ( isRaftFlag(combobuf[tmpscr[0].data[combo]].flag) || isRaftFlag(tmpscr[0].sflag[combo]));
24732
24733 87 }
24734 4865 int32_t HeroClass::lookahead(int32_t d2) // Helper for scrollscr that gets next combo on next screen.
24735 {
24736 // Can use destscr for scrolling warps,
24737 // but assumes currmap is correct.
24738
24739 4865 int32_t cx = vbound(x,0,240); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
24740 4865 int32_t cy = vbound(y + 8,0,160);
24741 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24742 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24743 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
24744
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1473 times.
✓ Branch 2 taken 879 times.
✓ Branch 3 taken 1151 times.
✓ Branch 4 taken 1362 times.
4865 switch(d2)
24745 {
24746 case up:
24747 1473 cy=160;
24748 1473 break;
24749
24750 case down:
24751 879 cy=0;
24752 879 break;
24753
24754 case left:
24755 1151 cx=240;
24756 1151 break;
24757
24758 case right:
24759 1362 cx=0;
24760 1362 break;
24761 }
24762
24763 4865 int32_t combo = (cy&0xF0)+(cx>>4);
24764
24765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4865 times.
4865 if(combo>175)
24766 return 0;
24767
24768 4865 return tmpscr[0].data[combo]; // entire combo code
24769 4865 }
24770
24771 4865 int32_t HeroClass::lookaheadflag(int32_t d2)
24772 {
24773 // Helper for scrollscr that gets next combo on next screen.
24774 // Can use destscr for scrolling warps,
24775 // but assumes currmap is correct.
24776
24777 4865 int32_t cx = vbound(x,0,240);
24778 4865 int32_t cy = vbound(y + 8,0,160);
24779
24780 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24781 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24782 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
24783 //Applying this here, too. -Z
24784
24785
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1473 times.
✓ Branch 2 taken 879 times.
✓ Branch 3 taken 1151 times.
✓ Branch 4 taken 1362 times.
4865 switch(d2)
24786 {
24787 case up:
24788 1473 cy=160;
24789 1473 break;
24790
24791 case down:
24792 879 cy=0;
24793 879 break;
24794
24795 case left:
24796 1151 cx=240;
24797 1151 break;
24798
24799 case right:
24800 1362 cx=0;
24801 1362 break;
24802 }
24803
24804 4865 int32_t combo = (cy&0xF0)+(cx>>4);
24805
24806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4865 times.
4865 if(combo>175)
24807 return 0;
24808
24809
2/2
✓ Branch 0 taken 4716 times.
✓ Branch 1 taken 149 times.
4865 if(!tmpscr[0].sflag[combo])
24810 {
24811 4716 return combobuf[tmpscr[0].data[combo]].flag; // flag
24812 }
24813
24814 149 return tmpscr[0].sflag[combo]; // flag
24815 4865 }
24816
24817 //Bit of a messy kludge to give the correct Hero->X/Hero->Y in the script
24818 720057 void HeroClass::run_scrolling_script(int32_t scrolldir, int32_t cx, int32_t sx, int32_t sy, bool end_frames, bool waitdraw)
24819 {
24820 // For rafting (and possibly other esoteric things)
24821 // Hero's action should remain unchanged while scrolling,
24822 // but for the sake of scripts, here's an eye-watering kludge.
24823 720057 actiontype lastaction = action;
24824 720057 action=scrolling; FFCore.setHeroAction(scrolling);
24825
2/2
✓ Branch 0 taken 359921 times.
✓ Branch 1 taken 360136 times.
720057 if(waitdraw)
24826 {
24827 359921 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
24828 359921 }
24829 else
24830 {
24831 360136 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS-1);
24832 }
24833 720057 zfix storex = x, storey = y;
24834
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 194261 times.
✓ Branch 2 taken 108948 times.
✓ Branch 3 taken 188748 times.
✓ Branch 4 taken 228100 times.
720057 switch(scrolldir)
24835 {
24836 case up:
24837
2/2
✓ Branch 0 taken 165271 times.
✓ Branch 1 taken 28990 times.
194261 if(y < 160) y = 176;
24838
4/4
✓ Branch 0 taken 24835 times.
✓ Branch 1 taken 4155 times.
✓ Branch 2 taken 8022 times.
✓ Branch 3 taken 16813 times.
28990 else if(cx > 0 && !end_frames) y = sy + 156;
24839 12177 else y = 160;
24840
24841 194261 break;
24842
24843 case down:
24844
2/2
✓ Branch 0 taken 92795 times.
✓ Branch 1 taken 16153 times.
108948 if(y > 0) y = -16;
24845
4/4
✓ Branch 0 taken 13633 times.
✓ Branch 1 taken 2520 times.
✓ Branch 2 taken 5068 times.
✓ Branch 3 taken 8565 times.
16153 else if(cx > 0 && !end_frames) y = sy - 172;
24846 7588 else y = 0;
24847
24848 108948 break;
24849
24850 case left:
24851
2/2
✓ Branch 0 taken 173779 times.
✓ Branch 1 taken 14969 times.
188748 if(x < 240) x = 256;
24852
2/2
✓ Branch 0 taken 12615 times.
✓ Branch 1 taken 2354 times.
14969 else if(cx > 0) x = sx + 236;
24853 2354 else x = 240;
24854
24855 188748 break;
24856
24857 case right:
24858
2/2
✓ Branch 0 taken 210088 times.
✓ Branch 1 taken 18012 times.
228100 if(x > 0) x = -16;
24859
2/2
✓ Branch 0 taken 15226 times.
✓ Branch 1 taken 2786 times.
18012 else if(cx > 0) x = sx - 252;
24860 2786 else x = 0;
24861
24862 228100 break;
24863 }
24864
2/2
✓ Branch 0 taken 359921 times.
✓ Branch 1 taken 360136 times.
720057 if(waitdraw)
24865 {
24866
3/4
✓ Branch 0 taken 359921 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 301810 times.
✓ Branch 3 taken 58111 times.
359921 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (global_wait & (1<<GLOBAL_SCRIPT_GAME)))
24867 {
24868 58111 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
24869 58111 global_wait&= ~(1<<GLOBAL_SCRIPT_GAME);
24870 58111 }
24871 359921 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
24872
4/6
✓ Branch 0 taken 359921 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3407 times.
✓ Branch 3 taken 356514 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3407 times.
359921 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && player_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24873 {
24874 3407 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
24875 3407 player_waitdraw = false;
24876 3407 }
24877 359921 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
24878
4/6
✓ Branch 0 taken 359921 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 359887 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 34 times.
359921 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24879 {
24880 34 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
24881 34 dmap_waitdraw = false;
24882 34 }
24883 359921 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
24884
2/6
✓ Branch 0 taken 359921 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 359921 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
359921 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24885 {
24886 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
24887 passive_subscreen_waitdraw = false;
24888 }
24889 359921 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
24890
4/10
✓ Branch 0 taken 359921 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 359904 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
359921 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->screen_waitdraw && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24891 {
24892 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
24893 tmpscr->screen_waitdraw = 0;
24894 }
24895 359921 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
24896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 359921 times.
359921 if ( !FFCore.system_suspend[susptITEMSCRIPTENGINE] )
24897 {
24898 359921 FFCore.itemScriptEngineOnWaitdraw();
24899 359921 }
24900 359921 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
24901 359921 }
24902 else
24903 {
24904
4/8
✓ Branch 0 taken 360136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 360118 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
360136 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24905 {
24906 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
24907 }
24908 360136 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS);
24909
3/4
✓ Branch 0 taken 360136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249368 times.
✓ Branch 3 taken 110768 times.
360136 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (g_doscript & (1<<GLOBAL_SCRIPT_GAME)))
24910 {
24911 110768 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
24912 110768 }
24913 360136 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_ACTIVE);
24914
5/6
✓ Branch 0 taken 360136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 352721 times.
✓ Branch 3 taken 7415 times.
✓ Branch 4 taken 349314 times.
✓ Branch 5 taken 3407 times.
360136 if ((!( FFCore.system_suspend[susptHEROACTIVE] )) && player_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255)
24915 {
24916 3407 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
24917 3407 }
24918 360136 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_ACTIVE);
24919
4/6
✓ Branch 0 taken 360136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 360136 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 349314 times.
✓ Branch 5 taken 10822 times.
360136 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24920 {
24921 10822 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
24922 10822 }
24923 360136 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE);
24924
4/6
✓ Branch 0 taken 360136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 360136 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 349314 times.
✓ Branch 5 taken 10822 times.
360136 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
24925 {
24926 10822 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
24927 10822 }
24928 360136 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN);
24929 360136 bool old = get_bit(quest_rules, qr_OLD_ITEMDATA_SCRIPT_TIMING);
24930
3/4
✓ Branch 0 taken 360136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4640 times.
✓ Branch 3 taken 355496 times.
360136 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && old)
24931 355496 FFCore.itemScriptEngine();
24932 360136 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_OLD_ITEMDATA_SCRIPT);
24933
3/4
✓ Branch 0 taken 360136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355496 times.
✓ Branch 3 taken 4640 times.
360136 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && !old)
24934 4640 FFCore.itemScriptEngine();
24935 }
24936
24937 720057 x = storex, y = storey;
24938
24939 720057 action=lastaction; FFCore.setHeroAction(lastaction);
24940 720057 }
24941
24942 //Has solving the maze enabled a side warp?
24943 //Only used just before scrolling screens
24944 // Note: since scrollscr() calls this, and dowarp() calls scrollscr(),
24945 // return true to abort the topmost scrollscr() call. -L
24946 4865 bool HeroClass::maze_enabled_sizewarp(int32_t scrolldir)
24947 {
24948
2/2
✓ Branch 0 taken 14595 times.
✓ Branch 1 taken 4865 times.
19460 for(int32_t i = 0; i < 3; i++) lastdir[i] = lastdir[i+1];
24949
24950
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 4796 times.
4865 lastdir[3] = tmpscr->flags&fMAZE ? scrolldir : 0xFF;
24951
24952
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4865 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4865 if(tmpscr->flags8&fMAZEvSIDEWARP && tmpscr->flags&fMAZE && scrolldir != tmpscr->exitdir)
24953 {
24954 switch(scrolldir)
24955 {
24956 case up:
24957 if(tmpscr->flags2&wfUP && checkmaze(tmpscr,true))
24958 {
24959 lastdir[3] = 0xFF;
24960 sdir=up;
24961 dowarp(1,(tmpscr->sidewarpindex)&3);
24962 return true;
24963 }
24964
24965 break;
24966
24967 case down:
24968 if(tmpscr->flags2&wfDOWN && checkmaze(tmpscr,true))
24969 {
24970 lastdir[3] = 0xFF;
24971 sdir=down;
24972 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
24973 return true;
24974 }
24975
24976 break;
24977
24978 case left:
24979 if(tmpscr->flags2&wfLEFT && checkmaze(tmpscr,true))
24980 {
24981 lastdir[3] = 0xFF;
24982 sdir=left;
24983 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
24984 return true;
24985 }
24986
24987 break;
24988
24989 case right:
24990 if(tmpscr->flags2&wfRIGHT && checkmaze(tmpscr,true))
24991 {
24992 lastdir[3] = 0xFF;
24993 sdir=right;
24994 dowarp(1,(tmpscr->sidewarpindex)&3);
24995 return true;
24996 }
24997
24998 break;
24999 }
25000 }
25001
25002 4865 return false;
25003 4865 }
25004
25005 4865 int32_t HeroClass::get_scroll_step(int32_t scrolldir)
25006 {
25007 // For side-scrollers, where the relative speed of 'fast' scrolling is a bit slow.
25008
2/2
✓ Branch 0 taken 554 times.
✓ Branch 1 taken 4311 times.
4865 if(get_bit(quest_rules, qr_VERYFASTSCROLLING))
25009 554 return 16;
25010
25011
2/2
✓ Branch 0 taken 3282 times.
✓ Branch 1 taken 1029 times.
4311 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) != 0)
25012 {
25013
2/2
✓ Branch 0 taken 1327 times.
✓ Branch 1 taken 1955 times.
3282 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 2 : 4;
25014 }
25015 else
25016 {
25017
4/4
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 155 times.
✓ Branch 3 taken 547 times.
1029 if(scrolldir == up || scrolldir == down)
25018 {
25019 482 return 8;
25020 }
25021 else
25022 {
25023
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 332 times.
547 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 2 : 4;
25024 }
25025 }
25026 4865 }
25027
25028 4865 int32_t HeroClass::get_scroll_delay(int32_t scrolldir)
25029 {
25030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4865 times.
4865 if(get_bit(quest_rules, qr_NOSCROLL))
25031 return 0;
25032
25033
4/4
✓ Branch 0 taken 4311 times.
✓ Branch 1 taken 554 times.
✓ Branch 2 taken 3282 times.
✓ Branch 3 taken 1029 times.
4865 if( (get_bit(quest_rules, qr_VERYFASTSCROLLING) != 0) ||
25034 4311 (get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) != 0) )
25035 {
25036 3836 return 1;
25037 }
25038 else
25039 {
25040
4/4
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 155 times.
✓ Branch 3 taken 547 times.
1029 if(scrolldir == up || scrolldir == down)
25041 {
25042
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 234 times.
482 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 4 : 2;
25043 }
25044 else
25045 {
25046 547 return 1;
25047 }
25048 }
25049 4865 }
25050
25051 5545 void HeroClass::calc_darkroom_hero(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
25052 {
25053 5545 int32_t itemid = current_item_id(itype_lantern);
25054
1/2
✓ Branch 0 taken 5545 times.
✗ Branch 1 not taken.
5545 if(itemid < 0) return; //no lantern light circle
25055 5545 int32_t hx1 = x.getInt() - x1 + 8;
25056 5545 int32_t hy1 = y.getInt() - y1 + 8;
25057 5545 int32_t hx2 = x.getInt() - x2 + 8;
25058 5545 int32_t hy2 = y.getInt() - y2 + 8;
25059
25060 5545 itemdata& lamp = itemsbuf[itemid];
25061
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5545 times.
✗ Branch 2 not taken.
5545 switch(lamp.misc1) //Shape
25062 {
25063 case 0: //Circle
25064 5545 doDarkroomCircle(hx1, hy1, lamp.misc2, darkscr_bmp_curscr);
25065 5545 doDarkroomCircle(hx2, hy2, lamp.misc2, darkscr_bmp_scrollscr);
25066 5545 break;
25067 case 1: //Lamp Cone
25068 doDarkroomCone(hx1, hy1, lamp.misc2, dir, darkscr_bmp_curscr);
25069 doDarkroomCone(hx2, hy2, lamp.misc2, dir, darkscr_bmp_scrollscr);
25070 break;
25071 }
25072 5545 }
25073
25074 4865 void HeroClass::scrollscr(int32_t scrolldir, int32_t destscr, int32_t destdmap)
25075 {
25076
2/4
✓ Branch 0 taken 4865 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4865 times.
4865 if(action==freeze||action==sideswimfreeze)
25077 {
25078 return;
25079 }
25080
25081 4865 bool overlay = false;
25082
25083
2/4
✓ Branch 0 taken 4865 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4865 times.
4865 if(scrolldir >= 0 && scrolldir <= 3)
25084 {
25085 4865 overlay = get_bit(&tmpscr[(currscr < 128) ? 0 : 1].sidewarpoverlayflags, scrolldir) ? true : false;
25086 4865 }
25087
25088
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 4797 times.
4865 if(destdmap == -1)
25089 {
25090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4797 times.
4797 if(ZCMaps[currmap].tileWidth != ZCMaps[DMaps[currdmap].map].tileWidth
25091
1/2
✓ Branch 0 taken 4797 times.
✗ Branch 1 not taken.
4797 || ZCMaps[currmap].tileHeight != ZCMaps[DMaps[currdmap].map].tileHeight)
25092 return;
25093 4797 }
25094 else
25095 {
25096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(ZCMaps[currmap].tileWidth != ZCMaps[DMaps[destdmap].map].tileWidth
25097
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 || ZCMaps[currmap].tileHeight != ZCMaps[DMaps[destdmap].map].tileHeight)
25098 return;
25099 }
25100
25101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4865 times.
4865 if(maze_enabled_sizewarp(scrolldir)) // dowarp() was called
25102 return;
25103
25104 4865 kill_enemy_sfx();
25105 4865 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
25106 4865 screenscrolling = true;
25107 4865 FFCore.ScrollingData[SCROLLDATA_DIR] = scrolldir;
25108
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1473 times.
✓ Branch 2 taken 879 times.
✓ Branch 3 taken 1151 times.
✓ Branch 4 taken 1362 times.
4865 switch(scrolldir)
25109 {
25110 case up:
25111 1473 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25112 1473 FFCore.ScrollingData[SCROLLDATA_NY] = -176;
25113 1473 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25114 1473 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25115 1473 break;
25116 case down:
25117 879 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25118 879 FFCore.ScrollingData[SCROLLDATA_NY] = 176;
25119 879 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25120 879 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25121 879 break;
25122 case left:
25123 1151 FFCore.ScrollingData[SCROLLDATA_NX] = -256;
25124 1151 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25125 1151 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25126 1151 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25127 1151 break;
25128 case right:
25129 1362 FFCore.ScrollingData[SCROLLDATA_NX] = 256;
25130 1362 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25131 1362 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25132 1362 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25133 1362 break;
25134 }
25135 4865 FFCore.init_combo_doscript();
25136 4865 tmpscr[1] = tmpscr[0];
25137
25138 4865 const int32_t _mapsSize = ZCMaps[currmap].tileWidth * ZCMaps[currmap].tileHeight;
25139
25140
2/2
✓ Branch 0 taken 29190 times.
✓ Branch 1 taken 4865 times.
34055 for(int32_t i = 0; i < 6; i++)
25141 {
25142 29190 tmpscr3[i] = tmpscr2[i];
25143 29190 }
25144
25145 4865 conveyclk = 2;
25146
25147 4865 mapscr *newscr = &tmpscr[0];
25148 4865 mapscr *oldscr = &tmpscr[1];
25149
25150 //scroll x, scroll y, old screen x, old screen y, new screen x, new screen y
25151 4865 int32_t sx = 0, sy = 0, tx = 0, ty = 0, tx2 = 0, ty2 = 0;
25152 4865 int32_t cx = 0;
25153 4865 int32_t step = get_scroll_step(scrolldir);
25154 4865 int32_t delay = get_scroll_delay(scrolldir);
25155 4865 bool end_frames = false;
25156
25157 4865 int32_t scx = get_bit(quest_rules,qr_FASTDNGN) ? 30 : 0;
25158
2/2
✓ Branch 0 taken 4311 times.
✓ Branch 1 taken 554 times.
4865 if(get_bit(quest_rules, qr_VERYFASTSCROLLING)) //just a minor adjustment.
25159 554 scx = 32; //for sideview very fast screolling.
25160
25161
25162 4865 int32_t lastattackclk = attackclk, lastspins = spins, lastcharging = charging; bool lasttapping = tapping;
25163 4865 actiontype lastaction = action;
25164 4865 ALLOFF(false, false);
25165 // for now, restore Hero's previous action
25166
2/2
✓ Branch 0 taken 4650 times.
✓ Branch 1 taken 215 times.
4865 if(!get_bit(quest_rules, qr_SCROLLING_KILLS_CHARGE))
25167 4865 attackclk = lastattackclk; spins = lastspins; charging = lastcharging; tapping = lasttapping;
25168 4865 action=lastaction; FFCore.setHeroAction(lastaction);
25169
25170 4865 lstep = (lstep + 6) % 12;
25171 4865 cx = scx;
25172 4865 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
25173
3/4
✓ Branch 0 taken 4865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3480 times.
✓ Branch 3 taken 1385 times.
4865 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (global_wait & (1<<GLOBAL_SCRIPT_GAME)))
25174 {
25175 1385 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
25176 1385 global_wait &= ~(1<<GLOBAL_SCRIPT_GAME);
25177 1385 }
25178 4865 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
25179
4/6
✓ Branch 0 taken 4865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 194 times.
✓ Branch 3 taken 4671 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 194 times.
4865 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && player_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25180 {
25181 194 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
25182 194 player_waitdraw = false;
25183 194 }
25184 4865 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
25185
4/6
✓ Branch 0 taken 4865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4863 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
4865 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25186 {
25187 2 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
25188 2 dmap_waitdraw = false;
25189 2 }
25190 4865 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
25191
2/6
✓ Branch 0 taken 4865 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4865 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4865 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25192 {
25193 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
25194 passive_subscreen_waitdraw = false;
25195 }
25196 4865 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
25197
2/8
✓ Branch 0 taken 4865 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4865 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4865 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->screen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25198 {
25199 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
25200 tmpscr->screen_waitdraw = 0;
25201 }
25202 4865 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
25203
25204 4865 word c = tmpscr->numFFC();
25205
2/2
✓ Branch 0 taken 150003 times.
✓ Branch 1 taken 4865 times.
154868 for ( word q = 0; q < c; ++q )
25206 {
25207 //Z_scripterrlog("tmpscr->ffcswaitdraw is: %d\n", tmpscr->ffcswaitdraw);
25208
1/2
✓ Branch 0 taken 150003 times.
✗ Branch 1 not taken.
150003 if ( tmpscr->ffcswaitdraw&(1<<q) )
25209 {
25210 //Z_scripterrlog("FFC (%d) called Waitdraw()\n", q);
25211 if(tmpscr->ffcs[q].script != 0)
25212 {
25213 ZScriptVersion::RunScript(SCRIPT_FFC, tmpscr->ffcs[q].script, q);
25214 tmpscr->ffcswaitdraw &= ~(1<<q);
25215 }
25216 }
25217 150003 }
25218 4865 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFC_WAITDRAW);
25219 4865 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_COMBO_WAITDRAW);
25220 //Waitdraw for item scripts.
25221 4865 FFCore.itemScriptEngineOnWaitdraw();
25222 4865 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
25223 4865 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_NPC_WAITDRAW);
25224
25225 //Sprite scripts on Waitdraw
25226 4865 FFCore.eweaponScriptEngineOnWaitdraw();
25227 4865 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_EWPN_WAITDRAW);
25228 4865 FFCore.itemSpriteScriptEngineOnWaitdraw();
25229 4865 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEMSPRITE_WAITDRAW);
25230
25231 //This is no longer a do-while, as the first iteration is now slightly different. -Em
25232 4865 draw_screen(tmpscr,true,true);
25233
25234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4865 times.
4865 if(cx == scx)
25235 4865 rehydratelake(false);
25236
25237 4865 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
25238 4865 advanceframe(true);
25239
25240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4865 times.
4865 if(Quit)
25241 {
25242 screenscrolling = false;
25243 return;
25244 }
25245
25246 4865 ++cx;
25247
2/2
✓ Branch 0 taken 103641 times.
✓ Branch 1 taken 4865 times.
108506 while(cx < 32)
25248 {
25249
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 103627 times.
103641 if(get_bit(quest_rules,qr_FIXSCRIPTSDURINGSCROLLING))
25250 {
25251 14 script_drawing_commands.Clear();
25252 14 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
25253 14 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
25254 14 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
25255 14 }
25256 103627 else FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
25257 103641 draw_screen(tmpscr,true,true);
25258
25259
1/2
✓ Branch 0 taken 103641 times.
✗ Branch 1 not taken.
103641 if(cx == scx)
25260 rehydratelake(false);
25261
25262 103641 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
25263 103641 advanceframe(true);
25264
25265
1/2
✓ Branch 0 taken 103641 times.
✗ Branch 1 not taken.
103641 if(Quit)
25266 {
25267 screenscrolling = false;
25268 return;
25269 }
25270
25271 103641 ++cx;
25272 }
25273 4865 script_drawing_commands.Clear();
25274 4865 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
25275
25276
25277 //clear Hero's last hits
25278 //for ( int32_t q = 0; q < 4; q++ ) sethitHeroUID(q, 0);
25279
25280
3/4
✓ Branch 0 taken 1951 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 496 times.
✓ Branch 3 taken 2418 times.
4865 switch(DMaps[currdmap].type&dmfTYPE)
25281 {
25282 case dmDNGN:
25283
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(!get_bit(quest_rules, qr_DUNGEONS_USE_CLASSIC_CHARTING))
25284 {
25285 markBmap(scrolldir);
25286 }
25287 2418 break;
25288 case dmOVERW: case dmBSOVERW:
25289
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 1889 times.
1951 if(get_bit(quest_rules, qr_NO_OVERWORLD_MAP_CHARTING))
25290 1889 break;
25291 [[fallthrough]];
25292 case dmCAVE:
25293 558 markBmap(scrolldir);
25294 558 break;
25295 }
25296
25297
1/2
✓ Branch 0 taken 4865 times.
✗ Branch 1 not taken.
4865 if(fixed_door)
25298 {
25299 unsetmapflag(mSECRET);
25300 fixed_door = false;
25301 }
25302 //Z_scripterrlog("Setting 'scrolling_scr' from %d to %d\n", scrolling_scr, currscr);
25303 4865 scrolling_scr = currscr;
25304
25305
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1473 times.
✓ Branch 2 taken 879 times.
✓ Branch 3 taken 1151 times.
✓ Branch 4 taken 1362 times.
4865 switch(scrolldir)
25306 {
25307 case up:
25308 {
25309
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 1461 times.
1473 if(destscr != -1)
25310 12 currscr = destscr;
25311
3/4
✓ Branch 0 taken 1437 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1437 times.
1461 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25312 1437 currscr -= 16;
25313
25314 1473 loadscr(0,destdmap,currscr,scrolldir,overlay);
25315 1473 blit(scrollbuf,scrollbuf,0,0,0,176,256,176);
25316 1473 putscr(scrollbuf,0,0,newscr);
25317 1473 putscrdoors(scrollbuf,0,0,newscr);
25318 1473 sy=176;
25319
25320
2/2
✓ Branch 0 taken 1146 times.
✓ Branch 1 taken 327 times.
1473 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) == 0)
25321 327 sy+=3;
25322
25323 1473 cx=176/step;
25324 1473 FFCore.init_combo_doscript();
25325 }
25326 1473 break;
25327
25328 case down:
25329 {
25330
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 861 times.
879 if(destscr != -1)
25331 18 currscr = destscr;
25332
3/4
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 855 times.
861 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25333 855 currscr += 16;
25334
25335 879 loadscr(0,destdmap,currscr,scrolldir,overlay);
25336 879 putscr(scrollbuf,0,176,newscr);
25337 879 putscrdoors(scrollbuf,0,176,newscr);
25338 879 sy = 0;
25339
25340
2/2
✓ Branch 0 taken 724 times.
✓ Branch 1 taken 155 times.
879 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) == 0)
25341 155 sy+=3;
25342
25343 879 cx = 176 / step;
25344 879 FFCore.init_combo_doscript();
25345 }
25346 879 break;
25347
25348 case left:
25349 {
25350
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1142 times.
1151 if(destscr!=-1)
25351 9 currscr = destscr;
25352
3/4
✓ Branch 0 taken 1131 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1131 times.
1142 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25353 1131 --currscr;
25354
25355 1151 loadscr(0,destdmap,currscr,scrolldir,overlay);
25356 1151 blit(scrollbuf,scrollbuf,0,0,256,0,256,176);
25357 1151 putscr(scrollbuf,0,0,newscr);
25358 1151 putscrdoors(scrollbuf,0,0,newscr);
25359 1151 sx = 256;
25360 1151 cx = 256 / step;
25361 1151 FFCore.init_combo_doscript();
25362 }
25363 1151 break;
25364
25365 case right:
25366 {
25367
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 1333 times.
1362 if(destscr != -1)
25368 29 currscr = destscr;
25369
3/4
✓ Branch 0 taken 1327 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1327 times.
1333 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25370 1327 ++currscr;
25371
25372 1362 loadscr(0,destdmap,currscr,scrolldir,overlay);
25373 1362 putscr(scrollbuf,256,0,newscr);
25374 1362 putscrdoors(scrollbuf,256,0,tmpscr);
25375 1362 sx = 0;
25376 1362 cx = 256 / step;
25377 1362 FFCore.init_combo_doscript();
25378 }
25379 1362 break;
25380 }
25381
25382 // change Hero's state if entering water
25383 4865 int32_t ahead = lookahead(scrolldir);
25384 4865 int32_t aheadflag = lookaheadflag(scrolldir);
25385 4865 int32_t lookaheadx = vbound(x+8,0,240); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
25386 4865 int32_t lookaheady = vbound(y + (bigHitbox?8:12),0,160);
25387 4865 int32_t wateraheadx1 = vbound(x+4,0,240);
25388 4865 int32_t wateraheadx2 = vbound(x+11,0,240);;
25389 4865 int32_t wateraheady1 = vbound(y+9,0,160);
25390 4865 int32_t wateraheady2 = vbound(y+15,0,160);
25391 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
25392 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
25393 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
25394
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1473 times.
✓ Branch 2 taken 879 times.
✓ Branch 3 taken 1151 times.
✓ Branch 4 taken 1362 times.
4865 switch(scrolldir)
25395 {
25396 case up:
25397 1473 lookaheady=160;
25398 1473 wateraheady1=160;
25399 1473 wateraheady2=160;
25400 1473 break;
25401
25402 case down:
25403 879 lookaheady=0;
25404 879 wateraheady1=0;
25405 879 wateraheady2=0;
25406 879 break;
25407
25408 case left:
25409 1151 lookaheadx=240;
25410 1151 wateraheadx1=240;
25411 1151 wateraheadx2=240;
25412 1151 break;
25413
25414 case right:
25415 1362 lookaheadx=0;
25416 1362 wateraheadx1=0;
25417 1362 wateraheadx2=0;
25418 1362 break;
25419 }
25420
25421 4865 bool nowinwater = false;
25422
25423
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 4845 times.
4865 if(lastaction != inwind)
25424 {
25425
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 4758 times.
4845 if(lastaction == rafting ) //&& isRaftFlag(aheadflag))
25426 {
25427
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 80 times.
87 if (lookaheadraftflag(scrolldir))
25428 {
25429 80 action=rafting; FFCore.setHeroAction(rafting);
25430 80 raftclk=0;
25431 80 }
25432 87 }
25433
5/6
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 4672 times.
✓ Branch 2 taken 86 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✓ Branch 5 taken 65 times.
4758 else if(iswaterex(ahead, currmap, currscr, -1, wateraheadx1,wateraheady1) && iswaterex(ahead, currmap, currscr, -1, wateraheadx2,wateraheady2) && (current_item(itype_flippers)))
25434 {
25435
9/16
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3 times.
✗ Branch 15 not taken.
65 if(lastaction==swimming || lastaction == sideswimming || lastaction == sideswimattacking || lastaction == sideswimhit || lastaction == swimhit || lastaction == sideswimcasting || lastaction == sidewaterhold1 || lastaction == sidewaterhold2)
25436 {
25437 62 SetSwim();
25438 62 hopclk = 0xFF;
25439 62 nowinwater = true;
25440 62 }
25441 else
25442 {
25443 3 action=hopping; FFCore.setHeroAction(hopping);
25444 3 hopclk = 2;
25445 3 nowinwater = true;
25446 }
25447 65 }
25448
2/4
✓ Branch 0 taken 4693 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4693 times.
4693 else if((lastaction == attacking || lastaction == sideswimattacking) && charging)
25449 {
25450 action = lastaction; FFCore.setHeroAction(lastaction);
25451 }
25452 else
25453 {
25454 4693 action=none; FFCore.setHeroAction(none);
25455 }
25456 4845 }
25457
25458 // The naturaldark state can be read/set by an FFC script before
25459 // fade() or lighting() is called.
25460 4865 naturaldark = ((TheMaps[currmap*MAPSCRS+currscr].flags & fDARK) != 0);
25461
25462
2/2
✓ Branch 0 taken 4759 times.
✓ Branch 1 taken 106 times.
4865 if(newscr->oceansfx != oldscr->oceansfx) adjust_sfx(oldscr->oceansfx, 128, false);
25463
25464
2/2
✓ Branch 0 taken 4732 times.
✓ Branch 1 taken 133 times.
4865 if(newscr->bosssfx != oldscr->bosssfx) adjust_sfx(oldscr->bosssfx, 128, false);
25465 //Preloaded ffc scripts
25466 4865 homescr=currscr;
25467 4865 auto olddmap = currdmap;
25468
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 4797 times.
4865 auto newdmap = (destdmap >= 0) ? destdmap : currdmap;
25469
25470 4865 currdmap = newdmap;
25471 4865 ffscript_engine(true);
25472 4865 currdmap = olddmap;
25473
25474 // There are two occasions when scrolling must be darkened:
25475 // 1) When scrolling into a dark room.
25476 // 2) When scrolling between DMaps of different colours.
25477
4/4
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 4797 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 16 times.
4865 if(destdmap != -1 && DMaps[destdmap].color != currcset)
25478 {
25479
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 fade((specialcave > 0) ? (specialcave >= GUYCAVE) ? 10 : 11 : currcset, true, false);
25480 16 darkroom = true;
25481 16 }
25482
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 4706 times.
4849 else if(!darkroom)
25483 4706 lighting(false, false); // NES behaviour: fade to dark before scrolling
25484
25485
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 4778 times.
4865 if(action != rafting) // Is this supposed to be here?!
25486
25487 4778 cx++; //This was the easiest way to re-arrange the loop so drawing is in the middle
25488
25489 4865 cx *= delay; //so we can have drawing re-done every frame,
25490 //previously it was for(0 to delay) advanceframes at end of loop
25491 4865 int32_t no_move = 0;
25492
25493 4865 currdmap = newdmap;
25494
4/4
✓ Branch 0 taken 4865 times.
✓ Branch 1 taken 359907 times.
✓ Branch 2 taken 359907 times.
✓ Branch 3 taken 4865 times.
364772 for(word i = 0; cx >= 0 && delay != 0; i++, cx--) //Go!
25495 {
25496
3/4
✓ Branch 0 taken 359907 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 238458 times.
✓ Branch 3 taken 121449 times.
359907 if (replay_is_active() && replay_get_version() < 3)
25497 {
25498 121449 replay_poll();
25499 121449 }
25500
1/2
✓ Branch 0 taken 359907 times.
✗ Branch 1 not taken.
359907 if(Quit)
25501 {
25502 screenscrolling = false;
25503 return;
25504 }
25505
25506
25507 359907 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false);
25508
25509
2/2
✓ Branch 0 taken 323314 times.
✓ Branch 1 taken 36593 times.
359907 if(no_move > 0)
25510 36593 no_move--;
25511
25512 //Don't want to move things on the first or last iteration, or between delays
25513
6/6
✓ Branch 0 taken 355042 times.
✓ Branch 1 taken 4865 times.
✓ Branch 2 taken 348307 times.
✓ Branch 3 taken 6735 times.
✓ Branch 4 taken 23129 times.
✓ Branch 5 taken 325178 times.
359907 if(i == 0 || cx == 0 || cx % delay != 0)
25514 34729 no_move++;
25515
25516
4/4
✓ Branch 0 taken 262809 times.
✓ Branch 1 taken 97098 times.
✓ Branch 2 taken 54454 times.
✓ Branch 3 taken 208355 times.
359907 if(scrolldir == up || scrolldir == down)
25517 {
25518
2/2
✓ Branch 0 taken 116375 times.
✓ Branch 1 taken 35177 times.
151552 if(!get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING))
25519 {
25520 //Add a few extra frames if on the second loop and cool scrolling is not set
25521
2/2
✓ Branch 0 taken 34695 times.
✓ Branch 1 taken 482 times.
35177 if(i == 1)
25522 {
25523 482 cx += (scrolldir == down) ? 3 : 2;
25524 482 no_move += (scrolldir == down) ? 3 : 2;
25525 482 }
25526 35177 }
25527 else
25528 {
25529 //4 frames after we've finished scrolling of being still
25530
4/4
✓ Branch 0 taken 3740 times.
✓ Branch 1 taken 112635 times.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 1870 times.
116375 if(cx == 0 && !end_frames)
25531 {
25532 1870 cx += 4;
25533 1870 no_move += 4;
25534 1870 end_frames = true;
25535 1870 }
25536 }
25537 151552 }
25538
25539 //Move Hero and the scroll position
25540
2/2
✓ Branch 0 taken 41458 times.
✓ Branch 1 taken 318449 times.
359907 if(!no_move)
25541 {
25542
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 72788 times.
✓ Branch 2 taken 42332 times.
✓ Branch 3 taken 92042 times.
✓ Branch 4 taken 111287 times.
318449 switch(scrolldir)
25543 {
25544 case up:
25545 72788 sy -= step;
25546 72788 y += step;
25547 72788 break;
25548
25549 case down:
25550 42332 sy += step;
25551 42332 y -= step;
25552 42332 break;
25553
25554 case left:
25555 92042 sx -= step;
25556 92042 x += step;
25557 92042 break;
25558
25559 case right:
25560 111287 sx += step;
25561 111287 x -= step;
25562 111287 break;
25563 }
25564
25565 //bound Hero when me move him off the screen in the last couple of frames of scrolling
25566
2/2
✓ Branch 0 taken 6298 times.
✓ Branch 1 taken 312151 times.
318449 if(y > 160) y = 160;
25567
25568
2/2
✓ Branch 0 taken 3552 times.
✓ Branch 1 taken 314897 times.
318449 if(y < 0) y = 0;
25569
25570
2/2
✓ Branch 0 taken 5732 times.
✓ Branch 1 taken 312717 times.
318449 if(x > 240) x = 240;
25571
25572
2/2
✓ Branch 0 taken 6932 times.
✓ Branch 1 taken 311517 times.
318449 if(x < 0) x = 0;
25573
25574
4/4
✓ Branch 0 taken 318203 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 318193 times.
318449 if(ladderx > 0 || laddery > 0)
25575 {
25576 // If the ladder moves on both axes, the player can
25577 // gradually shift it by going back and forth
25578
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
256 if(scrolldir==up || scrolldir==down)
25579 laddery = y.getInt();
25580 else
25581 256 ladderx = x.getInt();
25582 256 }
25583 318449 }
25584
25585 //Drawing
25586 359907 tx = sx;
25587 359907 ty = sy;
25588 359907 tx2 = sx;
25589 359907 ty2 = sy;
25590
25591
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 114011 times.
✓ Branch 2 taken 54454 times.
✓ Branch 3 taken 94344 times.
✓ Branch 4 taken 97098 times.
359907 switch(scrolldir)
25592 {
25593 case right:
25594 114011 FFCore.ScrollingData[SCROLLDATA_NX] = 256-tx2;
25595 114011 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25596 114011 FFCore.ScrollingData[SCROLLDATA_OX] = -tx2;
25597 114011 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25598 114011 tx -= 256;
25599 114011 break;
25600
25601 case down:
25602 54454 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25603 54454 FFCore.ScrollingData[SCROLLDATA_NY] = 176-ty2;
25604 54454 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25605 54454 FFCore.ScrollingData[SCROLLDATA_OY] = -ty2;
25606 54454 ty -= 176;
25607 54454 break;
25608
25609 case left:
25610 94344 FFCore.ScrollingData[SCROLLDATA_NX] = -tx2;
25611 94344 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25612 94344 FFCore.ScrollingData[SCROLLDATA_OX] = 256-tx2;
25613 94344 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25614 94344 tx2 -= 256;
25615 94344 break;
25616
25617 case up:
25618 97098 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25619 97098 FFCore.ScrollingData[SCROLLDATA_NY] = -ty2;
25620 97098 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25621 97098 FFCore.ScrollingData[SCROLLDATA_OY] = 176-ty2;
25622 97098 ty2 -= 176;
25623 97098 break;
25624 }
25625
25626 //FFScript.OnWaitdraw()
25627 359907 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
25628
25629 359907 FFCore.runGenericPassiveEngine(SCR_TIMING_PRE_DRAW);
25630 359907 clear_bitmap(scrollbuf);
25631 359907 clear_bitmap(framebuf);
25632
25633
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 97098 times.
✓ Branch 2 taken 54454 times.
✓ Branch 3 taken 94344 times.
✓ Branch 4 taken 114011 times.
359907 switch(scrolldir)
25634 {
25635 case up:
25636
1/2
✓ Branch 0 taken 97098 times.
✗ Branch 1 not taken.
97098 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
25637
25638
1/2
✓ Branch 0 taken 97098 times.
✗ Branch 1 not taken.
97098 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, -176+playing_field_offset, 3);
25639
25640
1/2
✓ Branch 0 taken 97098 times.
✗ Branch 1 not taken.
97098 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
25641
25642
1/2
✓ Branch 0 taken 97098 times.
✗ Branch 1 not taken.
97098 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, -176+playing_field_offset, 3);
25643
25644 // Draw both screens' background layer primitives together, after both layers' combos.
25645 // Not ideal, but probably good enough for all realistic purposes.
25646
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97098 times.
✓ Branch 2 taken 97098 times.
✗ Branch 3 not taken.
97098 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25647
25648
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97098 times.
✓ Branch 2 taken 97098 times.
✗ Branch 3 not taken.
97098 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25649
25650 97098 putscr(scrollbuf, 0, 0, newscr);
25651 97098 putscr(scrollbuf, 0, 176, oldscr);
25652 97098 break;
25653
25654 case down:
25655
1/2
✓ Branch 0 taken 54454 times.
✗ Branch 1 not taken.
54454 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, -176+playing_field_offset, 2);
25656
25657
1/2
✓ Branch 0 taken 54454 times.
✗ Branch 1 not taken.
54454 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
25658
25659
1/2
✓ Branch 0 taken 54454 times.
✗ Branch 1 not taken.
54454 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, -176+playing_field_offset, 2);
25660
25661
1/2
✓ Branch 0 taken 54454 times.
✗ Branch 1 not taken.
54454 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
25662
25663
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54454 times.
✓ Branch 2 taken 54454 times.
✗ Branch 3 not taken.
54454 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25664
25665
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54454 times.
✓ Branch 2 taken 54454 times.
✗ Branch 3 not taken.
54454 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25666
25667 54454 putscr(scrollbuf, 0, 0, oldscr);
25668 54454 putscr(scrollbuf, 0, 176, newscr);
25669 54454 break;
25670
25671 case left:
25672
2/2
✓ Branch 0 taken 94278 times.
✓ Branch 1 taken 66 times.
94344 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
25673
25674
1/2
✓ Branch 0 taken 94344 times.
✗ Branch 1 not taken.
94344 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, -256, playing_field_offset, 3);
25675
25676
1/2
✓ Branch 0 taken 94344 times.
✗ Branch 1 not taken.
94344 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
25677
25678
1/2
✓ Branch 0 taken 94344 times.
✗ Branch 1 not taken.
94344 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, -256, playing_field_offset, 3);
25679
25680
4/4
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 94278 times.
✓ Branch 2 taken 94278 times.
✓ Branch 3 taken 66 times.
94344 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25681
25682
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94344 times.
✓ Branch 2 taken 94344 times.
✗ Branch 3 not taken.
94344 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25683
25684 94344 putscr(scrollbuf, 0, 0, newscr);
25685 94344 putscr(scrollbuf, 256, 0, oldscr);
25686 94344 break;
25687
25688 case right:
25689
2/2
✓ Branch 0 taken 113945 times.
✓ Branch 1 taken 66 times.
114011 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, -256, playing_field_offset, 2);
25690
25691
2/2
✓ Branch 0 taken 113945 times.
✓ Branch 1 taken 66 times.
114011 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
25692
25693
1/2
✓ Branch 0 taken 114011 times.
✗ Branch 1 not taken.
114011 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, -256, playing_field_offset, 2);
25694
25695
1/2
✓ Branch 0 taken 114011 times.
✗ Branch 1 not taken.
114011 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
25696
25697
4/4
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 113945 times.
✓ Branch 2 taken 113879 times.
✓ Branch 3 taken 132 times.
114011 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25698
25699
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114011 times.
✓ Branch 2 taken 114011 times.
✗ Branch 3 not taken.
114011 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25700
25701 114011 putscr(scrollbuf, 0, 0, oldscr);
25702 114011 putscr(scrollbuf, 256, 0, newscr);
25703 114011 break;
25704 }
25705
25706 359907 blit(scrollbuf, framebuf, sx, sy, 0, playing_field_offset, 256, 168);
25707 359907 do_primitives(framebuf, 0, newscr, 0, playing_field_offset);
25708
25709 359907 do_layer(framebuf, 0, 1, oldscr, tx2, ty2, 3);
25710 359907 do_layer(framebuf, 0, 1, newscr, tx, ty, 2, false, true);
25711
25712
2/2
✓ Branch 0 taken 349314 times.
✓ Branch 1 taken 10593 times.
359907 if(get_bit(quest_rules, qr_FFCSCROLL))
25713 {
25714 10593 do_layer(framebuf, -3, 0, oldscr, tx2, ty2, 3, true); //ffcs
25715 10593 do_layer(framebuf, -3, 0, newscr, tx, ty, 2, true);
25716 10593 }
25717
25718
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 359841 times.
359907 if(!(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) ) do_layer(framebuf, 0, 2, oldscr, tx2, ty2, 3);
25719
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 359775 times.
359907 if(!(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, newscr, tx, ty, 2, false, !(oldscr->flags7&fLAYER2BG));
25720
25721 //push blocks
25722 359907 do_layer(framebuf, -2, 0, oldscr, tx2, ty2, 3);
25723 359907 do_layer(framebuf, -2, 0, newscr, tx, ty, 2);
25724
2/2
✓ Branch 0 taken 352721 times.
✓ Branch 1 taken 7186 times.
359907 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
25725 {
25726 7186 do_layer(framebuf, -2, 1, oldscr, tx2, ty2, 3);
25727 7186 do_layer(framebuf, -2, 1, newscr, tx, ty, 2);
25728 7186 do_layer(framebuf, -2, 2, oldscr, tx2, ty2, 3);
25729 7186 do_layer(framebuf, -2, 2, newscr, tx, ty, 2);
25730 7186 }
25731
25732 359907 do_walkflags(framebuf, oldscr, tx2, ty2,3); //show walkflags if the cheat is on
25733 359907 do_walkflags(framebuf, newscr, tx, ty,2);
25734
25735 359907 do_effectflags(framebuf, oldscr, tx2, ty2,3); //show effectflags if the cheat is on
25736 359907 do_effectflags(framebuf, newscr, tx, ty,2);
25737
25738
25739 359907 putscrdoors(framebuf, 0-tx2, 0-ty2+playing_field_offset, oldscr);
25740 359907 putscrdoors(framebuf, 0-tx, 0-ty+playing_field_offset, newscr);
25741 359907 herostep();
25742
25743
5/6
✓ Branch 0 taken 359857 times.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 359807 times.
✓ Branch 4 taken 359857 times.
✓ Branch 5 taken 359857 times.
359907 if((z > 0 || fakez > 0) && (!get_bit(quest_rules,qr_SHADOWSFLICKER) || frame&1))
25744 {
25745 719664 drawshadow(framebuf, get_bit(quest_rules, qr_TRANSSHADOWS) != 0);
25746 719664 }
25747
25748
4/4
✓ Branch 0 taken 238577 times.
✓ Branch 1 taken 121330 times.
✓ Branch 2 taken 124919 times.
✓ Branch 3 taken 113658 times.
359907 if(!isdungeon() || get_bit(quest_rules,qr_FREEFORM))
25749 {
25750 246249 draw_under(framebuf); //draw the ladder or raft
25751 246249 decorations.draw2(framebuf, true);
25752 246249 draw(framebuf); //Hero
25753 246249 decorations.draw(framebuf, true);
25754 246249 }
25755
25756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 359907 times.
359907 if(!(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, oldscr, tx2, ty2, 3);
25757
25758 359907 do_layer(framebuf, 0, 4, oldscr, tx2, ty2, 3); //layer 4
25759 359907 do_layer(framebuf, -1, 0, oldscr, tx2, ty2, 3); //overhead combos
25760
2/2
✓ Branch 0 taken 355608 times.
✓ Branch 1 taken 4299 times.
359907 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
25761 {
25762 4299 do_layer(framebuf, -1, 1, oldscr, tx2, ty2, 3); //overhead combos
25763 4299 do_layer(framebuf, -1, 2, oldscr, tx2, ty2, 3); //overhead combos
25764 4299 }
25765 359907 do_layer(framebuf, 0, 5, oldscr, tx2, ty2, 3); //layer 5
25766 359907 do_layer(framebuf, -4, 0, oldscr, tx2, ty2, 3, true); //overhead FFCs
25767 359907 do_layer(framebuf, 0, 6, oldscr, tx2, ty2, 3); //layer 6
25768
25769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 359907 times.
359907 if(!(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, newscr, tx, ty, 2, false, !(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)));
25770
25771 359907 do_layer(framebuf, 0, 4, newscr, tx, ty, 2, false, true); //layer 4
25772 359907 do_layer(framebuf, -1, 0, newscr, tx, ty, 2); //overhead combos
25773
2/2
✓ Branch 0 taken 355608 times.
✓ Branch 1 taken 4299 times.
359907 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
25774 {
25775 4299 do_layer(framebuf, -1, 1, newscr, tx, ty, 2); //overhead combos
25776 4299 do_layer(framebuf, -1, 2, newscr, tx, ty, 2); //overhead combos
25777 4299 }
25778 359907 do_layer(framebuf, 0, 5, newscr, tx, ty, 2, false, true); //layer 5
25779 359907 do_layer(framebuf, -4, 0, newscr, tx, ty, 2, true); //overhead FFCs
25780 359907 do_layer(framebuf, 0, 6, newscr, tx, ty, 2, false, true); //layer 6
25781
25782
25783
1/2
✓ Branch 0 taken 359907 times.
✗ Branch 1 not taken.
359907 if(msg_bg_display_buf->clip == 0)
25784 {
25785 blit_msgstr_bg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
25786 }
25787
1/2
✓ Branch 0 taken 359907 times.
✗ Branch 1 not taken.
359907 if(msg_portrait_display_buf->clip == 0)
25788 {
25789 blit_msgstr_prt(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
25790 }
25791
1/2
✓ Branch 0 taken 359907 times.
✗ Branch 1 not taken.
359907 if(msg_txt_display_buf->clip == 0)
25792 {
25793 blit_msgstr_fg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
25794 }
25795
25796
6/6
✓ Branch 0 taken 10593 times.
✓ Branch 1 taken 349314 times.
✓ Branch 2 taken 10433 times.
✓ Branch 3 taken 160 times.
✓ Branch 4 taken 17 times.
✓ Branch 5 taken 10416 times.
359907 if(get_bit(quest_rules, qr_NEW_DARKROOM) && ((newscr->flags&fDARK)||(oldscr->flags&fDARK)))
25797 {
25798 177 clear_to_color(darkscr_bmp_curscr, game->get_darkscr_color());
25799 177 clear_to_color(darkscr_bmp_curscr_trans, game->get_darkscr_color());
25800 177 clear_to_color(darkscr_bmp_scrollscr, game->get_darkscr_color());
25801 177 clear_to_color(darkscr_bmp_scrollscr_trans, game->get_darkscr_color());
25802 177 calc_darkroom_combos(true);
25803 177 calc_darkroom_hero(FFCore.ScrollingData[SCROLLDATA_NX], FFCore.ScrollingData[SCROLLDATA_NY],FFCore.ScrollingData[SCROLLDATA_OX], FFCore.ScrollingData[SCROLLDATA_OY]);
25804 177 }
25805
25806
4/4
✓ Branch 0 taken 10593 times.
✓ Branch 1 taken 349314 times.
✓ Branch 2 taken 7074 times.
✓ Branch 3 taken 3519 times.
359907 if(get_bit(quest_rules, qr_NEW_DARKROOM) && get_bit(quest_rules, qr_NEWDARK_L6))
25807 {
25808 3519 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
25809 3519 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
25810 3519 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
25811
1/2
✓ Branch 0 taken 3519 times.
✗ Branch 1 not taken.
3519 if(newscr->flags & fDARK)
25812 {
25813 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
25814 {
25815 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
25816 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
25817 }
25818
25819 color_map = &trans_table2;
25820 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
25821 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
25822 else
25823 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
25824 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
25825 color_map = &trans_table;
25826 }
25827
1/2
✓ Branch 0 taken 3519 times.
✗ Branch 1 not taken.
3519 if(oldscr->flags & fDARK)
25828 {
25829 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
25830 {
25831 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
25832 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
25833 }
25834
25835 color_map = &trans_table2;
25836 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
25837 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
25838 else
25839 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
25840 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
25841 color_map = &trans_table;
25842 }
25843 3519 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
25844 3519 }
25845 359907 put_passive_subscr(framebuf, &QMisc, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
25846
2/2
✓ Branch 0 taken 221463 times.
✓ Branch 1 taken 138444 times.
359907 if(get_bit(quest_rules,qr_SUBSCREENOVERSPRITES))
25847 138444 do_primitives(framebuf, 7, newscr, 0, playing_field_offset);
25848
25849
4/4
✓ Branch 0 taken 10593 times.
✓ Branch 1 taken 349314 times.
✓ Branch 2 taken 7074 times.
✓ Branch 3 taken 3519 times.
359907 if(get_bit(quest_rules, qr_NEW_DARKROOM) && !get_bit(quest_rules, qr_NEWDARK_L6))
25850 {
25851 7074 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
25852 7074 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
25853 7074 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
25854
2/2
✓ Branch 0 taken 6914 times.
✓ Branch 1 taken 160 times.
7074 if(newscr->flags & fDARK)
25855 {
25856
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
25857 {
25858 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
25859 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
25860 }
25861
25862 160 color_map = &trans_table2;
25863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
25864 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
25865 else
25866 160 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
25867 160 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
25868 160 color_map = &trans_table;
25869 160 }
25870
2/2
✓ Branch 0 taken 6931 times.
✓ Branch 1 taken 143 times.
7074 if(oldscr->flags & fDARK)
25871 {
25872
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
25873 {
25874 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
25875 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
25876 }
25877
25878 143 color_map = &trans_table2;
25879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
143 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
25880 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
25881 else
25882 143 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
25883 143 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
25884 143 color_map = &trans_table;
25885 143 }
25886 7074 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
25887 7074 }
25888 359907 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DRAW);
25889
25890 //end drawing
25891 359907 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
25892 359907 advanceframe(true/*,true,false*/);
25893 359907 script_drawing_commands.Clear();
25894 359907 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
25895 359907 actiontype lastaction = action;
25896 359907 action=scrolling; FFCore.setHeroAction(scrolling);
25897 359907 FFCore.runF6Engine();
25898 //FFCore.runF6EngineScrolling(newscr,oldscr,tx,ty,tx2,ty2,sx,sy,scrolldir);
25899 359907 action=lastaction; FFCore.setHeroAction(lastaction);
25900 359907 }//end main scrolling loop (2 spaces tab width makes me sad =( )
25901 4865 currdmap = olddmap;
25902
25903 4865 clear_bitmap(msg_txt_display_buf);
25904 4865 set_clip_state(msg_txt_display_buf, 1);
25905 4865 clear_bitmap(msg_bg_display_buf);
25906 4865 set_clip_state(msg_bg_display_buf, 1);
25907 4865 clear_bitmap(msg_portrait_display_buf);
25908 4865 set_clip_state(msg_portrait_display_buf, 1);
25909
25910 //Move hero to the other side of the screen if scrolling's not turned on
25911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4865 times.
4865 if(get_bit(quest_rules, qr_NOSCROLL))
25912 {
25913 switch(scrolldir)
25914 {
25915 case up:
25916 y = 160;
25917 break;
25918
25919 case down:
25920 y = 0;
25921 break;
25922
25923 case left:
25924 x = 240;
25925 break;
25926
25927 case right:
25928 x = 0;
25929 break;
25930 }
25931 }
25932
25933
3/4
✓ Branch 0 taken 4864 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 4865 times.
✗ Branch 3 not taken.
4865 if((z > 0 || fakez > 0) && isSideViewHero())
25934 {
25935 y -= z;
25936 y -= fakez;
25937 z = 0;
25938 fakez = 0;
25939 }
25940
25941 4865 set_respawn_point(false);
25942 4865 trySideviewLadder();
25943 4865 warpx = -1;
25944 4865 warpy = -1;
25945
25946 4865 screenscrolling = false;
25947 4865 FFCore.ScrollingData[SCROLLDATA_DIR] = -1;
25948 4865 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25949 4865 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25950 4865 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25951 4865 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25952
25953
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 4797 times.
4865 if(destdmap != -1)
25954 {
25955 68 bool changedlevel = false;
25956 68 bool changeddmap = false;
25957
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 34 times.
68 if(olddmap != destdmap)
25958 {
25959 34 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
25960 34 changeddmap = true;
25961 34 }
25962
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 1 times.
68 if(DMaps[olddmap].level != DMaps[destdmap].level)
25963 {
25964 1 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
25965 1 changedlevel = true;
25966 1 }
25967 68 dlevel = DMaps[destdmap].level;
25968 68 currdmap = destdmap;
25969
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 34 times.
68 if(changeddmap)
25970 {
25971 34 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
25972 34 }
25973
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 1 times.
68 if(changedlevel)
25974 {
25975 1 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
25976 1 }
25977 68 }
25978
25979 //if Hero is going from non-water to water, and we set his animation to "hopping" above, we must now
25980 //change it to swimming - since we have manually moved Hero onto the first tile, the hopping code
25981 //will get confused and try to hop Hero onto the next (possibly nonexistant) water tile in his current
25982 //direction. -DD
25983
25984
2/2
✓ Branch 0 taken 4800 times.
✓ Branch 1 taken 65 times.
4865 if(nowinwater)
25985 {
25986 65 SetSwim();
25987 65 hopclk = 0xFF;
25988 65 }
25989
25990 // NES behaviour: Fade to light after scrolling
25991 4865 lighting(false, false); // No, we don't need to set naturaldark...
25992
25993 4865 init_dmap();
25994 4865 putscr(scrollbuf,0,0,newscr);
25995 4865 putscrdoors(scrollbuf,0,0,newscr);
25996
25997 // Check for raft flags
25998
6/6
✓ Branch 0 taken 4778 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 4713 times.
✓ Branch 3 taken 65 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 4662 times.
4865 if(action!=rafting && hopclk==0 && !toogam)
25999 {
26000
3/4
✓ Branch 0 taken 4659 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4659 times.
4662 if(MAPFLAG(x,y)==mfRAFT||MAPCOMBOFLAG(x,y)==mfRAFT)
26001 {
26002 3 sfx(tmpscr->secretsfx);
26003 3 action=rafting; FFCore.setHeroAction(rafting);
26004 3 raftclk=0;
26005 3 }
26006
26007 // Half a tile off?
26008
6/8
✓ Branch 0 taken 3530 times.
✓ Branch 1 taken 1129 times.
✓ Branch 2 taken 1328 times.
✓ Branch 3 taken 2202 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2457 times.
✓ Branch 6 taken 4659 times.
✗ Branch 7 not taken.
7116 else if((dir==left || dir==right) && (MAPFLAG(x,y+8)==mfRAFT||MAPCOMBOFLAG(x,y+8)==mfRAFT))
26009 {
26010 sfx(tmpscr->secretsfx);
26011 action=rafting; FFCore.setHeroAction(rafting);
26012 raftclk=0;
26013 }
26014 4662 }
26015
26016 4865 opendoors=0;
26017 4865 markBmap(-1);
26018
26019
2/2
✓ Branch 0 taken 2447 times.
✓ Branch 1 taken 2418 times.
4865 if(isdungeon())
26020 {
26021
3/3
✓ Branch 0 taken 1350 times.
✓ Branch 1 taken 600 times.
✓ Branch 2 taken 468 times.
2418 switch(tmpscr->door[scrolldir^1])
26022 {
26023 case dOPEN:
26024 case dUNLOCKED:
26025 case dOPENBOSS:
26026 1350 dir = scrolldir;
26027
26028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1350 times.
1350 if(action!=rafting)
26029 1350 stepforward(diagonalMovement?11:12, false);
26030
26031 1350 break;
26032
26033 case dSHUTTER:
26034 case d1WAYSHUTTER:
26035 600 dir = scrolldir;
26036
26037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 600 times.
600 if(action!=rafting)
26038 600 stepforward(diagonalMovement?21:24, false);
26039
26040 600 putdoor(scrollbuf,0,scrolldir^1,tmpscr->door[scrolldir^1]);
26041 600 opendoors=-4;
26042 600 sfx(WAV_DOOR);
26043 600 break;
26044
26045 default:
26046 468 dir = scrolldir;
26047
26048
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 421 times.
468 if(action!=rafting)
26049 421 stepforward(diagonalMovement?21:24, false);
26050 468 }
26051 2418 }
26052
26053
1/2
✓ Branch 0 taken 4865 times.
✗ Branch 1 not taken.
4865 if(action == scrolling)
26054 {
26055 action=none; FFCore.setHeroAction(none);
26056 }
26057
26058
2/4
✓ Branch 0 taken 4865 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4865 times.
4865 if(action != attacking && action != sideswimattacking)
26059 {
26060 4865 charging = 0;
26061 4865 tapping = false;
26062 4865 }
26063
26064 4865 map_bkgsfx(true);
26065
26066
2/2
✓ Branch 0 taken 4847 times.
✓ Branch 1 taken 18 times.
4865 if(newscr->flags2&fSECRET)
26067 {
26068 18 sfx(newscr->secretsfx);
26069 18 }
26070
26071 4865 playLevelMusic();
26072
26073 4865 newscr_clk = frame;
26074 4865 activated_timed_warp=false;
26075 4865 loadside = scrolldir^1;
26076 4865 FFCore.init_combo_doscript();
26077 4865 eventlog_mapflags();
26078 4865 decorations.animate(); //continue to animate tall grass during scrolling
26079
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 4650 times.
4865 if(get_bit(quest_rules,qr_FIXSCRIPTSDURINGSCROLLING))
26080 {
26081 //script_drawing_commands.Clear();
26082 215 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
26083 //ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
26084 215 }
26085 4865 }
26086
26087
26088
26089 // How much to reduce Hero's damage, taking into account various rings.
26090 4308 int32_t HeroClass::ringpower(int32_t dmg, bool noPeril, bool noRing)
26091 {
26092
1/2
✓ Branch 0 taken 4308 times.
✗ Branch 1 not taken.
4308 if(dmg < 0) return dmg; //Don't reduce healing
26093
2/2
✓ Branch 0 taken 4178 times.
✓ Branch 1 taken 130 times.
4308 if ( get_bit(quest_rules,qr_BROKEN_RING_POWER) )
26094 {
26095 4178 int32_t divisor = 1;
26096 4178 float percentage = 1;
26097 4178 int32_t itemid = current_item_id(itype_ring);
26098 4178 bool usering = false;
26099
26100
4/4
✓ Branch 0 taken 3362 times.
✓ Branch 1 taken 816 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 3334 times.
4178 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
26101 {
26102 3334 usering = true;
26103 3334 paymagiccost(itemid);
26104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3334 times.
3334 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26105 {
26106 percentage *= itemsbuf[itemid].power/100.0;
26107 }
26108 else
26109 {
26110 3334 divisor *= itemsbuf[itemid].power;
26111 }
26112 3334 }
26113
26114 /* Now for the Peril Ring */
26115 4178 itemid = current_item_id(itype_perilring);
26116
26117
7/10
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 3744 times.
✓ Branch 2 taken 434 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 427 times.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 7 times.
4178 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
26118 {
26119 7 usering = true;
26120 7 paymagiccost(itemid);
26121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26122 {
26123 percentage *= itemsbuf[itemid].power/100.0;
26124 }
26125 else
26126 {
26127 7 divisor *= itemsbuf[itemid].power;
26128 }
26129 7 }
26130
26131 // Ring divisor of 0 = no damage. -L
26132
4/6
✓ Branch 0 taken 3341 times.
✓ Branch 1 taken 837 times.
✓ Branch 2 taken 3341 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3341 times.
4178 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
26133 return 0;
26134
26135
1/2
✓ Branch 0 taken 4178 times.
✗ Branch 1 not taken.
4178 if( percentage < 0 ) percentage = (percentage * -1) + 1; //Negative percentage = that percent MORE damage -V
26136
26137
1/2
✓ Branch 0 taken 4178 times.
✗ Branch 1 not taken.
4178 if ( divisor < 0 ) return dmg * percentage * (divisor*-1);
26138
1/2
✓ Branch 0 taken 4178 times.
✗ Branch 1 not taken.
4178 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
26139
26140 }
26141 else
26142 {
26143 130 double divisor = 1;
26144 130 double percentage = 1;
26145 130 int32_t itemid = current_item_id(itype_ring);
26146 130 bool usering = false;
26147
26148
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
130 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
26149 {
26150 1 usering = true;
26151 1 paymagiccost(itemid);
26152
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26153 {
26154 1 double perc = itemsbuf[itemid].power/100.0;
26155
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
26156 1 percentage *= perc;
26157 1 }
26158 else
26159 {
26160 if(itemsbuf[itemid].power < 0)
26161 divisor /= -(itemsbuf[itemid].power);
26162 else divisor *= itemsbuf[itemid].power;
26163 }
26164 1 }
26165
26166 /* Now for the Peril Ring */
26167 130 itemid = current_item_id(itype_perilring);
26168
26169
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
130 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
26170 {
26171 usering = true;
26172 paymagiccost(itemid);
26173 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26174 {
26175 double perc = itemsbuf[itemid].power/100.0;
26176 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
26177 percentage *= perc;
26178 }
26179 else
26180 {
26181 if(itemsbuf[itemid].power < 0)
26182 divisor /= -(itemsbuf[itemid].power);
26183 else divisor *= itemsbuf[itemid].power;
26184 }
26185 }
26186
26187 // Ring divisor of 0 = no damage. -L
26188
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 129 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
130 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
26189 return 0;
26190
26191 //if ( divisor < 0 ) return dmg * percentage * (divisor*-1); //handle this further up now
26192
1/2
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
130 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
26193 }
26194 4308 }
26195
26196 // Should swinging the hammer make the 'pound' sound?
26197 // Or is Hero just hitting air?
26198 252 bool HeroClass::sideviewhammerpound()
26199 {
26200 252 int32_t wx=0,wy=0;
26201
26202
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 114 times.
252 switch(dir)
26203 {
26204 case up:
26205 81 wx=-1;
26206 81 wy=-15;
26207
26208
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(isSideViewHero()) wy+=8;
26209
26210 81 break;
26211
26212 case down:
26213 51 wx=8;
26214 51 wy=28;
26215
26216
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(isSideViewHero()) wy-=8;
26217
26218 51 break;
26219
26220 case left:
26221 6 wx=-8;
26222 6 wy=14;
26223
26224
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(isSideViewHero()) wy+=8;
26225
26226 6 break;
26227
26228 case right:
26229 114 wx=21;
26230 114 wy=14;
26231
26232
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(isSideViewHero()) wy+=8;
26233
26234 114 break;
26235 }
26236
26237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!isSideViewHero())
26238 {
26239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 return (COMBOTYPE(x+wx,y+wy)!=cSHALLOWWATER && !iswaterex(MAPCOMBO(x+wx,y+wy), currmap, currscr, -1, x+wx,y+wy));
26240 }
26241
26242 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
26243
26244 if(dir==left || dir==right)
26245 {
26246 wx+=16;
26247
26248 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
26249 }
26250
26251 return false;
26252 252 }
26253
26254 /************************************/
26255 /******** More Items Code *********/
26256 /************************************/
26257
26258 // The following are only used for Hero damage. Damage is in quarter hearts.
26259 2252 int32_t enemy_dp(int32_t index)
26260 {
26261 2252 return (((enemy*)guys.spr(index))->dp)*(game->get_ene_dmgmult());
26262 }
26263
26264 1965 int32_t ewpn_dp(int32_t index)
26265 {
26266 1965 return (((weapon*)Ewpns.spr(index))->power)*(game->get_ene_dmgmult());
26267 }
26268
26269 18 int32_t lwpn_dp(int32_t index)
26270 {
26271 18 return (((weapon*)Lwpns.spr(index))->power)*(game->get_ene_dmgmult());
26272 }
26273
26274 49917450 bool checkbunny(int32_t itemid)
26275 {
26276
1/4
✓ Branch 0 taken 49917450 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
49917450 return !Hero.BunnyClock() || (itemid > 0 && itemsbuf[itemid].flags&ITEM_BUNNY_ENABLED);
26277 }
26278
26279 12562969 bool usesSwordJinx(int32_t itemid)
26280 {
26281 12562969 itemdata const& it = itemsbuf[itemid];
26282 12562969 bool ret = (it.family==itype_sword);
26283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12562969 times.
12562969 if(it.flags & ITEM_FLIP_JINX) return !ret;
26284 12562969 return ret;
26285 12562969 }
26286 10733237 bool checkitem_jinx(int32_t itemid)
26287 {
26288 10733237 itemdata const& it = itemsbuf[itemid];
26289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10733237 times.
10733237 if(it.flags & ITEM_JINX_IMMUNE) return true;
26290
2/2
✓ Branch 0 taken 3027587 times.
✓ Branch 1 taken 7705650 times.
10733237 if(usesSwordJinx(itemid)) return HeroSwordClk() == 0;
26291 7705650 return HeroItemClk() == 0;
26292 10733237 }
26293
26294 189380 int32_t Bweapon(int32_t pos)
26295 {
26296
3/4
✓ Branch 0 taken 189380 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593 times.
✓ Branch 3 taken 188787 times.
189380 if(pos < 0 || current_subscreen_active == NULL)
26297 {
26298 593 return 0;
26299 }
26300
26301 188787 int32_t p=-1;
26302
26303
4/4
✓ Branch 0 taken 53587 times.
✓ Branch 1 taken 5764768 times.
✓ Branch 2 taken 53587 times.
✓ Branch 3 taken 5764768 times.
5818355 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL && i < MAXSUBSCREENITEMS; ++i)
26304 {
26305
4/4
✓ Branch 0 taken 4055805 times.
✓ Branch 1 taken 1708963 times.
✓ Branch 2 taken 3920605 times.
✓ Branch 3 taken 135200 times.
5764768 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM && current_subscreen_active->objects[i].d3==pos)
26306 {
26307 135200 p=i;
26308 135200 break;
26309 }
26310 5629568 }
26311
26312
2/2
✓ Branch 0 taken 135200 times.
✓ Branch 1 taken 53587 times.
188787 if(p==-1)
26313 {
26314 53587 return 0;
26315 }
26316
26317 135200 int32_t actualItem = current_subscreen_active->objects[p].d8;
26318 //int32_t familyCheck = actualItem ? itemsbuf[actualItem].family : current_subscreen_active->objects[p].d1
26319 135200 int32_t family = -1;
26320 135200 bool bow = false;
26321
26322
2/2
✓ Branch 0 taken 743 times.
✓ Branch 1 taken 134457 times.
135200 if(actualItem)
26323 {
26324 743 bool select = false;
26325
26326
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 743 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
743 switch(itemsbuf[actualItem-1].family)
26327 {
26328 case itype_bomb:
26329 if((game->get_bombs() ||
26330 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26331 (actualItem-1>-1 && itemsbuf[actualItem-1].misc1==0 && findWeaponWithParent(actualItem-1, wLitBomb))) ||
26332 current_item_power(itype_bombbag))
26333 {
26334 select=true;
26335 }
26336
26337 break;
26338
26339 case itype_bowandarrow:
26340 case itype_arrow:
26341 if(actualItem-1>-1 && current_item_id(itype_bow)>-1)
26342 {
26343 //bow=(current_subscreen_active->objects[p].d1==itype_bowandarrow);
26344 select=true;
26345 }
26346
26347 break;
26348
26349 case itype_letterpotion:
26350 /*if(current_item_id(itype_potion)>-1)
26351 {
26352 select=true;
26353 }
26354 else if(current_item_id(itype_letter)>-1)
26355 {
26356 select=true;
26357 }*/
26358 break;
26359
26360 case itype_sbomb:
26361 {
26362 int32_t bombbagid = current_item_id(itype_bombbag);
26363
26364 if((game->get_sbombs() ||
26365 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26366 (actualItem-1>-1 && itemsbuf[actualItem-1].misc1==0 && findWeaponWithParent(actualItem-1, wLitSBomb))) ||
26367 (current_item_power(itype_bombbag) && bombbagid>-1 && (itemsbuf[bombbagid].flags & ITEM_FLAG1)))
26368 {
26369 select=true;
26370 }
26371
26372 break;
26373 }
26374
26375 case itype_sword:
26376 {
26377 if(!get_bit(quest_rules,qr_SELECTAWPN))
26378 break;
26379
26380 select=true;
26381 }
26382 break;
26383
26384 default:
26385 743 select=true;
26386 743 }
26387
26388
4/6
✓ Branch 0 taken 743 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 650 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 650 times.
743 if(!item_disabled(actualItem-1) && game->get_item(actualItem-1) && select)
26389 {
26390 650 directItem = actualItem-1;
26391
26392
2/4
✓ Branch 0 taken 650 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 650 times.
✗ Branch 3 not taken.
650 if(directItem>-1 && itemsbuf[directItem].family == itype_arrow) bow=true;
26393
26394 650 return actualItem-1+(bow?0xF000:0);
26395 }
26396 93 else return 0;
26397 }
26398
26399 134457 directItem = -1;
26400
26401
6/6
✓ Branch 0 taken 15294 times.
✓ Branch 1 taken 1540 times.
✓ Branch 2 taken 108578 times.
✓ Branch 3 taken 5980 times.
✓ Branch 4 taken 2578 times.
✓ Branch 5 taken 487 times.
134457 switch(current_subscreen_active->objects[p].d1)
26402 {
26403 case itype_bomb:
26404 {
26405 15294 int32_t bombid = current_item_id(itype_bomb);
26406
26407
3/4
✓ Branch 0 taken 4868 times.
✓ Branch 1 taken 10426 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4868 times.
20162 if((game->get_bombs() ||
26408 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26409
3/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 4843 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
4868 (bombid>-1 && itemsbuf[bombid].misc1==0 && Lwpns.idCount(wLitBomb)>0)) ||
26410 4868 current_item_power(itype_bombbag))
26411 {
26412 10426 family=itype_bomb;
26413 10426 }
26414
26415 15294 break;
26416 }
26417
26418 case itype_bowandarrow:
26419 case itype_arrow:
26420
4/4
✓ Branch 0 taken 4991 times.
✓ Branch 1 taken 989 times.
✓ Branch 2 taken 4990 times.
✓ Branch 3 taken 1 times.
5980 if(current_item_id(itype_bow)>-1 && current_item_id(itype_arrow)>-1)
26421 {
26422 4990 bow=(current_subscreen_active->objects[p].d1==itype_bowandarrow);
26423 4990 family=itype_arrow;
26424 4990 }
26425
26426 5980 break;
26427
26428 case itype_letterpotion:
26429
2/2
✓ Branch 0 taken 1424 times.
✓ Branch 1 taken 1154 times.
2578 if(current_item_id(itype_potion)>-1)
26430 {
26431 1424 family=itype_potion;
26432 1424 }
26433
2/2
✓ Branch 0 taken 882 times.
✓ Branch 1 taken 272 times.
1154 else if(current_item_id(itype_letter)>-1)
26434 {
26435 272 family=itype_letter;
26436 272 }
26437
26438 2578 break;
26439
26440 case itype_sbomb:
26441 {
26442 1540 int32_t bombbagid = current_item_id(itype_bombbag);
26443 1540 int32_t sbombid = current_item_id(itype_sbomb);
26444
26445
2/4
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 972 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1540 if((game->get_sbombs() ||
26446 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26447
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 568 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
568 (sbombid>-1 && itemsbuf[sbombid].misc1==0 && Lwpns.idCount(wLitSBomb)>0)) ||
26448
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 568 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
568 (current_item_power(itype_bombbag) && bombbagid>-1 && (itemsbuf[bombbagid].flags & ITEM_FLAG1)))
26449 {
26450 972 family=itype_sbomb;
26451 972 }
26452
26453 1540 break;
26454 }
26455
26456 case itype_sword:
26457 {
26458
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 30 times.
487 if(!get_bit(quest_rules,qr_SELECTAWPN))
26459 30 break;
26460
26461 457 family=itype_sword;
26462 }
26463 457 break;
26464
26465 default:
26466 108578 family=current_subscreen_active->objects[p].d1;
26467 108578 }
26468
26469
2/2
✓ Branch 0 taken 127119 times.
✓ Branch 1 taken 7338 times.
134457 if(family==-1)
26470 7338 return 0;
26471
26472
2/2
✓ Branch 0 taken 5828372 times.
✓ Branch 1 taken 9578 times.
5837950 for(int32_t j=0; j<MAXITEMS; j++)
26473 {
26474 // Find the item that matches this subscreen object.
26475
5/6
✓ Branch 0 taken 203641 times.
✓ Branch 1 taken 5624731 times.
✓ Branch 2 taken 117541 times.
✓ Branch 3 taken 86100 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 117541 times.
5828372 if(itemsbuf[j].family==family && j == current_item_id(family,false) && !item_disabled(j))
26476 {
26477 117541 return j+(bow?0xF000:0);
26478 }
26479 5710831 }
26480
26481 9578 return 0;
26482 189380 }
26483
26484 93 int32_t BWeapon_to_Pos(int32_t bweapon)
26485 {
26486
2/2
✓ Branch 0 taken 5272 times.
✓ Branch 1 taken 19 times.
5291 for (int32_t i = 0; i < MAXSUBSCREENITEMS; ++i)
26487 {
26488
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 5198 times.
5272 if (Bweapon(i) == bweapon)
26489 {
26490 74 return i;
26491 }
26492 5198 }
26493 19 return -1;
26494 93 }
26495
26496 void stopCaneOfByrna()
26497 {
26498 for(int32_t i=0; i<Lwpns.Count(); i++)
26499 {
26500 weapon *w = ((weapon*)Lwpns.spr(i));
26501 if(w->id==wCByrna)
26502 w->dead=1;
26503 }
26504 }
26505
26506 /* Crashes if used by ffscript.cpp, in case LINKITEMD
26507 void stopCaneOfByrna()
26508 {
26509 byte prnt_cane = -1;
26510 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
26511 prnt_cane = ew->parentitem;
26512 for(int32_t i=0; i<Lwpns.Count(); i++)
26513 {
26514 weapon *w = ((weapon*)Lwpns.spr(i));
26515
26516 if(w->id==wCByrna)
26517 {
26518 w->dead=1;
26519 }
26520 }
26521 if ( prnt_cane > -1 )
26522 {
26523 stop_sfx(itemsbuf[prnt_cane].usesound);
26524 }
26525 }
26526 */
26527 //Check if there are no beams, kill sfx, and reset last_cane_of_byrna_item_id
26528 3393649 void HeroClass::cleanupByrna()
26529 {
26530
1/2
✓ Branch 0 taken 3393649 times.
✗ Branch 1 not taken.
3393649 if ( last_cane_of_byrna_item_id > -1 )
26531 {
26532 //al_trace("Last cane id is: %d\n", last_cane_of_byrna_item_id);
26533 if ( !(Lwpns.idCount(wCByrna)) )
26534 {
26535 stop_sfx(itemsbuf[last_cane_of_byrna_item_id].usesound);
26536 last_cane_of_byrna_item_id = -1;
26537 }
26538 }
26539 3393649 }
26540
26541 // Used to find out if an item family is attached to one of the buttons currently pressed.
26542 1234603 bool isWpnPressed(int32_t itype)
26543 {
26544 //0xFFF for subscreen overrides
26545 //Will crash on win10 without it! -Z
26546
4/4
✓ Branch 0 taken 185450 times.
✓ Branch 1 taken 1049153 times.
✓ Branch 2 taken 162886 times.
✓ Branch 3 taken 22564 times.
1234603 if((itype==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return true;
26547
4/4
✓ Branch 0 taken 481847 times.
✓ Branch 1 taken 730192 times.
✓ Branch 2 taken 147293 times.
✓ Branch 3 taken 334554 times.
1212039 if((itype==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return true;
26548
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 877485 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
877485 if((itype==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return true;
26549
3/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 877465 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
877485 if((itype==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return true;
26550 877465 return false;
26551 1234603 }
26552
26553 3278288 int32_t getWpnPressed(int32_t itype)
26554 {
26555
4/4
✓ Branch 0 taken 155462 times.
✓ Branch 1 taken 3122826 times.
✓ Branch 2 taken 152216 times.
✓ Branch 3 taken 3246 times.
3278288 if((itype==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return Bwpn;
26556
3/4
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 3274456 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 586 times.
3275042 if((itype==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return Awpn;
26557
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3274456 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3274456 if((itype==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return Xwpn;
26558
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3274456 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3274456 if((itype==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return Ywpn;
26559
26560 3274456 return -1;
26561 3278288 }
26562
26563 3395231 int32_t getRocsPressed()
26564 {
26565 3395231 int32_t jumpid = current_item_id(itype_rocs,true,true);
26566
26567
2/2
✓ Branch 0 taken 185339 times.
✓ Branch 1 taken 3209892 times.
3395231 if(unsigned(jumpid) >= MAXITEMS) jumpid = -1;
26568
26569
2/2
✓ Branch 0 taken 3209892 times.
✓ Branch 1 taken 185339 times.
3395231 if (jumpid != -1)
26570 {
26571 185339 itemdata const& itm = itemsbuf[jumpid];
26572
26573 185339 byte intbtn = byte(itm.misc2&0xFF);
26574
1/2
✓ Branch 0 taken 185339 times.
✗ Branch 1 not taken.
185339 if(getIntBtnInput(intbtn, false, true, false, false, true))
26575 return jumpid; //not pressed
26576 185339 }
26577
26578
4/4
✓ Branch 0 taken 15394 times.
✓ Branch 1 taken 3379837 times.
✓ Branch 2 taken 14327 times.
✓ Branch 3 taken 1067 times.
3395231 if((itype_rocs==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return Bwpn;
26579
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3394164 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3394164 if((itype_rocs==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return Awpn;
26580
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3394164 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3394164 if((itype_rocs==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return Xwpn;
26581
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3394164 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3394164 if((itype_rocs==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return Ywpn;
26582
26583 3394164 return -1;
26584 3395231 }
26585
26586 bool isItmPressed(int32_t itmid)
26587 {
26588 if(itmid==(Bwpn&0xFFF) && DrunkcBbtn()) return true;
26589 if(itmid==(Awpn&0xFFF) && DrunkcAbtn()) return true;
26590 if(itmid==(Xwpn&0xFFF) && DrunkcEx1btn()) return true;
26591 if(itmid==(Ywpn&0xFFF) && DrunkcEx2btn()) return true;
26592 return false;
26593 }
26594
26595 1 void selectNextAWpn(int32_t type)
26596 {
26597
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!get_bit(quest_rules,qr_SELECTAWPN))
26598 return;
26599
26600
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 int32_t ret = selectWpn_new(type, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
26601 1 Awpn = Bweapon(ret);
26602 1 directItemA = directItem;
26603 1 game->awpn = ret;
26604 1 }
26605
26606 3803 void selectNextBWpn(int32_t type)
26607 {
26608
2/4
✓ Branch 0 taken 3803 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3803 times.
3803 int32_t ret = selectWpn_new(type, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
26609 3803 Bwpn = Bweapon(ret);
26610 3803 directItemB = directItem;
26611 3803 game->bwpn = ret;
26612 3803 }
26613
26614 void selectNextXWpn(int32_t type)
26615 {
26616 if(!get_bit(quest_rules,qr_SET_XBUTTON_ITEMS)) return;
26617 int32_t ret = selectWpn_new(type, game->xwpn, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
26618 Xwpn = Bweapon(ret);
26619 directItemX = directItem;
26620 game->xwpn = ret;
26621 }
26622
26623 void selectNextYWpn(int32_t type)
26624 {
26625 if(!get_bit(quest_rules,qr_SET_YBUTTON_ITEMS)) return;
26626 int32_t ret = selectWpn_new(type, game->ywpn, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1);
26627 Ywpn = Bweapon(ret);
26628 directItemY = directItem;
26629 game->ywpn = ret;
26630 }
26631
26632 26327 void verifyAWpn()
26633 {
26634
2/2
✓ Branch 0 taken 1021 times.
✓ Branch 1 taken 25306 times.
26327 if ( (game->forced_awpn != -1) )
26635 {
26636 1021 return;
26637 }
26638
2/2
✓ Branch 0 taken 25073 times.
✓ Branch 1 taken 233 times.
25306 if(!get_bit(quest_rules,qr_SELECTAWPN))
26639 {
26640 25073 Awpn = selectSword();
26641 25073 game->awpn = 0xFF;
26642 25073 }
26643 else
26644 {
26645 233 game->awpn = selectWpn_new(SEL_VERIFY_RIGHT, game->awpn, game->bwpn, game->xwpn, game->ywpn);
26646 233 Awpn = Bweapon(game->awpn);
26647 233 directItemA = directItem;
26648 }
26649 26327 }
26650
26651 24835 void verifyBWpn()
26652 {
26653
2/2
✓ Branch 0 taken 1015 times.
✓ Branch 1 taken 23820 times.
24835 if ( (game->forced_bwpn != -1) )
26654 {
26655 1015 return;
26656 }
26657 23820 game->bwpn = selectWpn_new(SEL_VERIFY_RIGHT, game->bwpn, game->awpn, game->xwpn, game->ywpn);
26658 23820 Bwpn = Bweapon(game->bwpn);
26659 23820 directItemB = directItem;
26660 24835 }
26661
26662 24835 void verifyXWpn()
26663 {
26664
2/2
✓ Branch 0 taken 1015 times.
✓ Branch 1 taken 23820 times.
24835 if ( (game->forced_xwpn != -1) )
26665 {
26666 1015 return;
26667 }
26668
2/2
✓ Branch 0 taken 23756 times.
✓ Branch 1 taken 64 times.
23820 if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS))
26669 64 game->xwpn = selectWpn_new(SEL_VERIFY_RIGHT, game->xwpn, game->awpn, game->bwpn, game->ywpn);
26670 23756 else game->xwpn = -1;
26671 23820 Xwpn = Bweapon(game->xwpn);
26672 23820 directItemX = directItem;
26673 24835 }
26674
26675 24835 void verifyYWpn()
26676 {
26677
2/2
✓ Branch 0 taken 1015 times.
✓ Branch 1 taken 23820 times.
24835 if ( (game->forced_ywpn != -1) )
26678 {
26679 1015 return;
26680 }
26681
2/2
✓ Branch 0 taken 23756 times.
✓ Branch 1 taken 64 times.
23820 if(get_bit(quest_rules,qr_SET_YBUTTON_ITEMS))
26682 64 game->ywpn = selectWpn_new(SEL_VERIFY_RIGHT, game->ywpn, game->awpn, game->xwpn, game->bwpn);
26683 23756 else game->ywpn = -1;
26684 23820 Ywpn = Bweapon(game->ywpn);
26685 23820 directItemY = directItem;
26686 24835 }
26687
26688 24835 void verifyBothWeapons()
26689 {
26690 24835 verifyAWpn();
26691 24835 verifyBWpn();
26692 24835 verifyXWpn();
26693 24835 verifyYWpn();
26694 24835 }
26695
26696 29171 int32_t selectWpn_new(int32_t type, int32_t startpos, int32_t forbiddenpos, int32_t fp2, int32_t fp3)
26697 {
26698 //what will be returned when all else fails.
26699 //don't return the forbiddenpos... no matter what -DD
26700
26701 29171 int32_t failpos(0);
26702
26703
6/6
✓ Branch 0 taken 28516 times.
✓ Branch 1 taken 655 times.
✓ Branch 2 taken 28451 times.
✓ Branch 3 taken 65 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 28447 times.
29171 if(startpos == forbiddenpos || startpos == fp2 || startpos == fp3)
26704 724 failpos = 0xFF;
26705 28447 else failpos = startpos;
26706
26707 // verify startpos
26708
3/4
✓ Branch 0 taken 29171 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 734 times.
✓ Branch 3 taken 28437 times.
29171 if(startpos < 0 || startpos >= 0xFF)
26709 734 startpos = 0;
26710
26711
2/2
✓ Branch 0 taken 28964 times.
✓ Branch 1 taken 207 times.
29171 if(current_subscreen_active == NULL)
26712 207 return failpos;
26713
26714
4/4
✓ Branch 0 taken 4901 times.
✓ Branch 1 taken 24063 times.
✓ Branch 2 taken 471 times.
✓ Branch 3 taken 4430 times.
28964 if(type==SEL_VERIFY_RIGHT || type==SEL_VERIFY_LEFT)
26715 {
26716 24534 int32_t wpn = Bweapon(startpos);
26717
26718
6/8
✓ Branch 0 taken 23160 times.
✓ Branch 1 taken 1374 times.
✓ Branch 2 taken 23156 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 23156 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 23156 times.
24534 if(wpn != 0 && startpos != forbiddenpos && startpos != fp2 && startpos != fp3)
26719 {
26720 23156 return startpos;
26721 }
26722 1378 }
26723
26724 5808 int32_t p=-1;
26725 5808 int32_t curpos = startpos;
26726 5808 int32_t firstValidPos=-1;
26727
26728
2/2
✓ Branch 0 taken 744 times.
✓ Branch 1 taken 145670 times.
146414 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL; ++i)
26729 {
26730
2/2
✓ Branch 0 taken 43605 times.
✓ Branch 1 taken 102065 times.
145670 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM)
26731 {
26732
4/4
✓ Branch 0 taken 84733 times.
✓ Branch 1 taken 17332 times.
✓ Branch 2 taken 79669 times.
✓ Branch 3 taken 5064 times.
102065 if(firstValidPos==-1 && current_subscreen_active->objects[i].d3>=0)
26733 {
26734 5064 firstValidPos=i;
26735 5064 }
26736
26737
2/2
✓ Branch 0 taken 97001 times.
✓ Branch 1 taken 5064 times.
102065 if(current_subscreen_active->objects[i].d3==curpos)
26738 {
26739 5064 p=i;
26740 5064 break;
26741 }
26742 97001 }
26743 140606 }
26744
26745
2/2
✓ Branch 0 taken 5064 times.
✓ Branch 1 taken 744 times.
5808 if(p == -1)
26746 {
26747 //can't find the current position
26748 // Switch to a valid weapon if there is one; otherwise,
26749 // the selector can simply disappear
26750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 744 times.
744 if(firstValidPos>=0)
26751 {
26752 return current_subscreen_active->objects[firstValidPos].d3;
26753 }
26754 //FAILURE
26755 else
26756 {
26757 744 return failpos;
26758 }
26759 }
26760
26761 //remember we've been here
26762 5064 set<int32_t> oldPositions;
26763
1/2
✓ Branch 0 taken 5064 times.
✗ Branch 1 not taken.
5064 oldPositions.insert(curpos);
26764
26765 //1. Perform any shifts required by the above
26766 //2. If that's not possible, go to position 1 and reset the b weapon.
26767 //2a. -if we arrive at a position we've already visited, give up and stay there
26768 //3. Get the weapon at the new slot
26769 //4. If it's not possible, go to step 1.
26770
26771 16909 for(;;)
26772 {
26773 //shift
26774
4/5
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 47 times.
✓ Branch 2 taken 2685 times.
✓ Branch 3 taken 14163 times.
✗ Branch 4 not taken.
16909 switch(type)
26775 {
26776 case SEL_LEFT:
26777 case SEL_VERIFY_LEFT:
26778 2685 curpos = current_subscreen_active->objects[p].d6;
26779 2685 break;
26780
26781 case SEL_RIGHT:
26782 case SEL_VERIFY_RIGHT:
26783 14163 curpos = current_subscreen_active->objects[p].d7;
26784 14163 break;
26785
26786 case SEL_DOWN:
26787 14 curpos = current_subscreen_active->objects[p].d5;
26788 14 break;
26789
26790 case SEL_UP:
26791 47 curpos = current_subscreen_active->objects[p].d4;
26792 47 break;
26793 }
26794
26795 //find our new position
26796 16909 p = -1;
26797
26798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 651363 times.
651363 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL; ++i)
26799 {
26800
2/2
✓ Branch 0 taken 144208 times.
✓ Branch 1 taken 507155 times.
651363 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM)
26801 {
26802
2/2
✓ Branch 0 taken 490246 times.
✓ Branch 1 taken 16909 times.
507155 if(current_subscreen_active->objects[i].d3==curpos)
26803 {
26804 16909 p=i;
26805 16909 break;
26806 }
26807 490246 }
26808 634454 }
26809
26810
1/2
✓ Branch 0 taken 16909 times.
✗ Branch 1 not taken.
16909 if(p == -1)
26811 {
26812 //can't find the current position
26813 //FAILURE
26814 return failpos;
26815 }
26816
26817 //if we've already been here, give up
26818
3/4
✓ Branch 0 taken 16909 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16011 times.
✓ Branch 3 taken 898 times.
16909 if(oldPositions.find(curpos) != oldPositions.end())
26819 {
26820 898 return failpos;
26821 }
26822
26823 //else, remember we've been here
26824
1/2
✓ Branch 0 taken 16011 times.
✗ Branch 1 not taken.
16011 oldPositions.insert(curpos);
26825
26826 //see if this weapon is acceptable
26827
9/10
✓ Branch 0 taken 16011 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4231 times.
✓ Branch 3 taken 11780 times.
✓ Branch 4 taken 4184 times.
✓ Branch 5 taken 47 times.
✓ Branch 6 taken 4174 times.
✓ Branch 7 taken 10 times.
✓ Branch 8 taken 8 times.
✓ Branch 9 taken 4166 times.
16011 if(Bweapon(curpos) != 0 && curpos != forbiddenpos && curpos != fp2 && curpos != fp3)
26828 4166 return curpos;
26829
26830 //keep going otherwise
26831 }
26832 29171 }
26833
26834 // Select the sword for the A button if the 'select A button weapon' quest rule isn't set.
26835 25156 int32_t selectSword()
26836 {
26837 25156 auto ret = current_item_id(itype_sword);
26838
2/2
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 24717 times.
25156 if(ret == -1) return 0;
26839 24717 return ret;
26840 25156 }
26841
26842 // Adding code here for allowing hardcoding a button to a specific itemclass.
26843 int32_t selectItemclass(int32_t itemclass)
26844 {
26845 int32_t ret = current_item_id(itemclass);
26846
26847 if(ret == -1)
26848 ret = 0;
26849
26850 return ret;
26851 }
26852
26853 // Used for the 'Pickup Hearts' item pickup condition.
26854 54 bool canget(int32_t id)
26855 {
26856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 return id>=0 && (game->get_maxlife()>=(itemsbuf[id].pickup_hearts*game->get_hp_per_heart()));
26857 }
26858
26859 24 void dospecialmoney(int32_t index)
26860 {
26861 24 int32_t tmp=currscr>=128?1:0;
26862 24 int32_t priceindex = ((item*)items.spr(index))->PriceIndex;
26863
26864
3/7
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10 times.
24 switch(tmpscr[tmp].room)
26865 {
26866 case rINFO: // pay for info
26867 if(prices[priceindex]!=100000 ) // 100000 is a placeholder price for free items
26868 {
26869
26870
26871 if(!current_item_power(itype_wallet))
26872 {
26873 if (game->get_spendable_rupies() < abs(prices[priceindex]))
26874 return;
26875 int32_t tmpprice = -abs(prices[priceindex]);
26876 int32_t total = game->get_drupy()-tmpprice;
26877 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
26878 game->set_drupy(game->get_drupy()-total);
26879 //game->change_drupy(-abs(prices[priceindex]));
26880 }
26881 if ( current_item_power(itype_wallet)>0 )
26882 {
26883 game->change_drupy(0);
26884 }
26885 }
26886 rectfill(msg_bg_display_buf, 0, 0, msg_bg_display_buf->w, 80, 0);
26887 rectfill(msg_txt_display_buf, 0, 0, msg_txt_display_buf->w, 80, 0);
26888 donewmsg(QMisc.info[tmpscr[tmp].catchall].str[priceindex]);
26889 clear_bitmap(pricesdisplaybuf);
26890 set_clip_state(pricesdisplaybuf, 1);
26891 items.del(0);
26892
26893 for(int32_t i=0; i<items.Count(); i++)
26894 ((item*)items.spr(i))->pickup=ipDUMMY;
26895
26896 // Prevent the prices from being displayed anymore
26897 for(int32_t i=0; i<3; i++)
26898 {
26899 prices[i] = 0;
26900 }
26901
26902 break;
26903
26904 case rMONEY: // secret money
26905 {
26906 11 ((item*)items.spr(0))->pickup = ipDUMMY;
26907
26908 11 prices[0] = tmpscr[tmp].catchall;
26909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!current_item_power(itype_wallet))
26910 11 game->change_drupy(prices[0]);
26911 //game->set_drupy(game->get_drupy()+price); may be needed everywhere
26912
26913 11 putprices(false);
26914
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
26915 11 break;
26916 }
26917
26918 case rGAMBLE: // gamble
26919 {
26920 if(game->get_spendable_rupies()<10 && !current_item_power(itype_wallet)) return; //Why 10?
26921
26922 unsigned si=(zc_oldrand()%24)*3;
26923
26924 for(int32_t i=0; i<3; i++)
26925 prices[i]=gambledat[si++];
26926
26927 game->set_drupy(game->get_drupy()+prices[priceindex]);
26928 putprices(true);
26929
26930 for(int32_t i=1; i<4; i++)
26931 ((item*)items.spr(i))->pickup=ipDUMMY;
26932 }
26933 break;
26934
26935 case rBOMBS:
26936 {
26937
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
26938 return;
26939
26940 3 int32_t price = -tmpscr[tmp].catchall;
26941 3 int32_t wmedal = current_item_id(itype_wealthmedal);
26942
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(wmedal >= 0)
26943 {
26944 if(itemsbuf[wmedal].flags & ITEM_FLAG1)
26945 price*=(itemsbuf[wmedal].misc1/100.0);
26946 else
26947 price+=itemsbuf[wmedal].misc1;
26948 }
26949
26950 3 int32_t total = game->get_drupy()-price;
26951 3 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
26952 3 game->set_drupy(game->get_drupy()-total);
26953 //game->set_drupy(game->get_drupy()+price);
26954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
26955 3 game->change_maxbombs(4);
26956 3 game->set_bombs(game->get_maxbombs());
26957 {
26958 3 int32_t div = zinit.bomb_ratio;
26959
26960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(div > 0)
26961 3 game->change_maxcounter(4/div, 6);
26962 }
26963
26964 //also give Hero an actual Bomb item
26965
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t i=0; i<MAXITEMS; i++)
26966 {
26967
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 763 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 3 times.
768 if(itemsbuf[i].family == itype_bomb && itemsbuf[i].fam_type == 1)
26968 3 getitem(i, true, true);
26969 768 }
26970
26971 3 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
26972 3 fadeclk=66;
26973 3 dismissmsg();
26974 3 clear_bitmap(pricesdisplaybuf);
26975 3 set_clip_state(pricesdisplaybuf, 1);
26976 // putscr(scrollbuf,0,0,tmpscr);
26977 3 verifyBothWeapons();
26978 3 break;
26979 }
26980
26981 case rARROWS:
26982 {
26983 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
26984 return;
26985
26986 int32_t price = -tmpscr[tmp].catchall;
26987 int32_t wmedal = current_item_id(itype_wealthmedal);
26988 if(wmedal >= 0)
26989 {
26990 if(itemsbuf[wmedal].flags & ITEM_FLAG1)
26991 price*=(itemsbuf[wmedal].misc1/100.0);
26992 else
26993 price+=itemsbuf[wmedal].misc1;
26994 }
26995
26996 int32_t total = game->get_drupy()-price;
26997 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
26998 game->set_drupy(game->get_drupy()-total);
26999
27000 //game->set_drupy(game->get_drupy()+price);
27001 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
27002 game->change_maxarrows(10);
27003 game->set_arrows(game->get_maxarrows());
27004 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
27005 fadeclk=66;
27006 dismissmsg();
27007 clear_bitmap(pricesdisplaybuf);
27008 set_clip_state(pricesdisplaybuf, 1);
27009 // putscr(scrollbuf,0,0,tmpscr);
27010 verifyBothWeapons();
27011 break;
27012 }
27013
27014 case rSWINDLE:
27015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(items.spr(index)->id==iRupy)
27016 {
27017
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
27018 return;
27019 10 int32_t tmpprice = -tmpscr[tmp].catchall;
27020 10 int32_t total = game->get_drupy()-tmpprice;
27021 10 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
27022 10 game->set_drupy(game->get_drupy()-total);
27023 10 }
27024 else
27025 {
27026 if(game->get_maxlife()<=game->get_hp_per_heart())
27027 return;
27028
27029 game->set_life(zc_max(game->get_life()-game->get_hp_per_heart(),0));
27030 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),(game->get_hp_per_heart())));
27031 }
27032
27033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
27034 10 ((item*)items.spr(0))->pickup=ipDUMMY+ipFADE;
27035 10 ((item*)items.spr(1))->pickup=ipDUMMY+ipFADE;
27036 10 fadeclk=66;
27037 10 dismissmsg();
27038 10 clear_bitmap(pricesdisplaybuf);
27039 10 set_clip_state(pricesdisplaybuf, 1);
27040 // putscr(scrollbuf,0,0,tmpscr);
27041 10 break;
27042 }
27043 24 }
27044
27045 5861 void getitem(int32_t id, bool nosound, bool doRunPassive)
27046 {
27047
1/2
✓ Branch 0 taken 5861 times.
✗ Branch 1 not taken.
5861 if(id<0)
27048 {
27049 return;
27050 }
27051
27052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5861 times.
5861 if (replay_is_active())
27053
1/2
✓ Branch 0 taken 5861 times.
✗ Branch 1 not taken.
5861 replay_step_comment(fmt::format("getitem {}", item_string[id]));
27054
27055
2/2
✓ Branch 0 taken 5855 times.
✓ Branch 1 taken 6 times.
5861 if(get_bit(quest_rules,qr_SCC_ITEM_COMBINES_ITEMS))
27056 {
27057 6 int32_t nextitem = -1;
27058 6 do
27059 {
27060 6 nextitem = -1;
27061
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if((itemsbuf[id].flags & ITEM_COMBINE) && game->get_item(id))
27062 // Item upgrade routine.
27063 {
27064
27065 for(int32_t i=0; i<MAXITEMS; i++)
27066 {
27067 // Find the item which is as close to this item's fam_type as possible.
27068 if(itemsbuf[i].family==itemsbuf[id].family && itemsbuf[i].fam_type>itemsbuf[id].fam_type
27069 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
27070 {
27071 nextitem = i;
27072 }
27073 }
27074
27075 if(nextitem>-1)
27076 {
27077 id = nextitem;
27078 if(!get_bit(quest_rules,qr_ITEMCOMBINE_CONTINUOUS))
27079 break; //no looping
27080 }
27081 }
27082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 } while(nextitem > -1);
27083 6 }
27084
27085 5861 itemdata const& idat = itemsbuf[id&0xFF];
27086 // if(idat.family!=0xFF) //1.92 compat... that already should be changed to 'itype_misc'? Blehg, hate this! -Em
27087 {
27088
4/4
✓ Branch 0 taken 539 times.
✓ Branch 1 taken 5322 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 504 times.
5861 if(idat.flags & ITEM_GAMEDATA && idat.family != itype_triforcepiece)
27089 {
27090 // Fix boomerang sounds.
27091 504 int32_t itemid = current_item_id(idat.family);
27092
27093
4/6
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 219 times.
✓ Branch 2 taken 280 times.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
504 if(itemid>=0 && (idat.family == itype_brang || idat.family == itype_nayruslove
27094
3/6
✓ Branch 0 taken 280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 280 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 280 times.
✗ Branch 5 not taken.
280 || idat.family == itype_hookshot || idat.family == itype_switchhook || idat.family == itype_cbyrna)
27095 285 && sfx_allocated(itemsbuf[itemid].usesound)
27096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 285 times.
285 && idat.usesound != itemsbuf[itemid].usesound)
27097 {
27098 stop_sfx(itemsbuf[itemid].usesound);
27099 cont_sfx(idat.usesound);
27100 }
27101
27102 504 int32_t curitm = current_item_id(idat.family);
27103
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
504 if(!get_bit(quest_rules,qr_KEEPOLD_APPLIES_RETROACTIVELY)
27104
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 504 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
504 || curitm < 0 || (itemsbuf[curitm].fam_type <= idat.fam_type)
27105 || (itemsbuf[curitm].flags & ITEM_KEEPOLD))
27106 {
27107 504 game->set_item(id,true);
27108 504 passiveitem_script(id, doRunPassive);
27109 504 }
27110
27111
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 371 times.
504 if(!(idat.flags & ITEM_KEEPOLD))
27112 {
27113
3/4
✓ Branch 0 taken 338 times.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 338 times.
371 if(!get_bit(quest_rules,qr_BROKEN_KEEPOLD_FLAG) || current_item(idat.family)<idat.fam_type)
27114 {
27115 33 removeLowerLevelItemsOfFamily(game,itemsbuf,idat.family, idat.fam_type);
27116 33 }
27117 371 }
27118
27119 // NES consistency: replace all flying boomerangs with the current boomerang.
27120
2/2
✓ Branch 0 taken 489 times.
✓ Branch 1 taken 15 times.
504 if(idat.family==itype_brang)
27121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 for(int32_t i=0; i<Lwpns.Count(); i++)
27122 {
27123 weapon *w = ((weapon*)Lwpns.spr(i));
27124
27125 if(w->id==wBrang)
27126 {
27127 w->LOADGFX(idat.wpn);
27128 }
27129 15 }
27130 504 }
27131
27132
2/2
✓ Branch 0 taken 930 times.
✓ Branch 1 taken 4931 times.
5861 if(idat.count!=-1)
27133 {
27134
2/2
✓ Branch 0 taken 4827 times.
✓ Branch 1 taken 104 times.
4931 if(idat.setmax)
27135 {
27136 // Bomb bags are a special case; they may be set not to increase super bombs
27137
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 101 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
104 if(idat.family==itype_bombbag && idat.count==2 && (idat.flags&16)==0)
27138 {
27139 int32_t max = game->get_maxbombs();
27140
27141 if(max<idat.max) max=idat.max;
27142
27143 game->set_maxbombs(zc_min(game->get_maxbombs()+idat.setmax,max), false);
27144 }
27145 else
27146 {
27147 104 int32_t max = game->get_maxcounter(idat.count);
27148
27149
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(max<idat.max) max=idat.max;
27150
27151
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 38 times.
104 game->set_maxcounter(zc_min(game->get_maxcounter(idat.count)+idat.setmax,max), idat.count);
27152 }
27153 104 }
27154
27155 // Amount is an uint16_t, but the range is -9999 to 16383
27156 // -1 is actually 16385 ... -9999 is 26383, and 0x8000 means use the drain counter
27157
2/2
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 4750 times.
4931 if(idat.amount&0x3FFF)
27158 {
27159
2/2
✓ Branch 0 taken 3290 times.
✓ Branch 1 taken 1460 times.
4750 if(idat.amount&0x8000)
27160 6580 game->set_dcounter(
27161
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3289 times.
3290 game->get_dcounter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
27162 else
27163 {
27164
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1460 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1460 if(idat.amount>=16385 && game->get_counter(0)<=idat.amount-16384)
27165 game->set_counter(0, idat.count);
27166 else
27167 // This is too confusing to try and change...
27168
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1460 times.
✓ Branch 2 taken 642 times.
✓ Branch 3 taken 818 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 642 times.
1460 game->set_counter(zc_min(game->get_counter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF),game->get_maxcounter(idat.count)), idat.count);
27169 }
27170 4750 }
27171 4931 }
27172 }
27173
27174
3/4
✓ Branch 0 taken 5861 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✓ Branch 3 taken 5749 times.
5861 if(idat.playsound&&!nosound)
27175 {
27176 5749 sfx(idat.playsound);
27177 5749 }
27178
27179 //add lower-level items
27180
2/2
✓ Branch 0 taken 5840 times.
✓ Branch 1 taken 21 times.
5861 if(idat.flags&ITEM_GAINOLD)
27181 {
27182
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 21 times.
38 for(int32_t i=idat.fam_type-1; i>0; i--)
27183 {
27184 17 int32_t potid = getItemID(itemsbuf, idat.family, i);
27185
27186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(potid != -1)
27187 {
27188 17 game->set_item(potid, true);
27189 17 }
27190 17 }
27191 21 }
27192
27193
10/14
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5271 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 237 times.
✓ Branch 6 taken 34 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 33 times.
✓ Branch 9 taken 28 times.
✓ Branch 10 taken 26 times.
✓ Branch 11 taken 195 times.
✓ Branch 12 taken 23 times.
✗ Branch 13 not taken.
5861 switch(idat.family)
27194 {
27195 case itype_itmbundle:
27196 {
27197 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
27198 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
27199 bool pscript = (idat.flags & ITEM_FLAG1);
27200 for(auto q = 0; q < 10; ++q)
27201 {
27202 if(unsigned(ids[q]) >= MAXITEMS) continue;
27203 if(pscript)
27204 collectitem_script(ids[q]);
27205 getitem(ids[q], true, true);
27206 }
27207 }
27208 break;
27209
27210 case itype_progressive_itm:
27211 {
27212 int32_t newid = get_progressive_item(idat);
27213 if(newid > -1)
27214 getitem(newid, nosound, true);
27215 }
27216 break;
27217
27218 case itype_bottlefill:
27219 {
27220 if(idat.misc1)
27221 {
27222 game->fillBottle(idat.misc1);
27223 }
27224 }
27225 break;
27226
27227 case itype_clock:
27228 {
27229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 237 times.
237 if(idat.flags & ITEM_FLAG1) //Active use, not passive
27230 break;
27231
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 237 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
237 if((idat.flags & ITEM_FLAG2) && clockclk) //"Can't activate while clock active"
27232 break;
27233 237 setClock(watch=true);
27234
27235
2/2
✓ Branch 0 taken 121344 times.
✓ Branch 1 taken 237 times.
121581 for(int32_t i=0; i<eMAXGUYS; i++)
27236 121344 clock_zoras[i]=0;
27237
27238 237 clockclk=itemsbuf[id&0xFF].misc1;
27239 237 sfx(idat.usesound);
27240 }
27241 237 break;
27242
27243 case itype_lkey:
27244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
34 if(game->lvlkeys[dlevel]<255) game->lvlkeys[dlevel]++;
27245 34 break;
27246
27247 case itype_ring:
27248 case itype_magicring:
27249
5/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
12 if((get_bit(quest_rules,qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
27250 {
27251 12 ringcolor(false);
27252 12 }
27253 12 break;
27254
27255 case itype_whispring:
27256 {
27257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(idat.flags & ITEM_FLAG1)
27258 {
27259
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(HeroSwordClk()==-1) setSwordClk(150); // Let's not bother applying the divisor.
27260
27261
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(HeroItemClk()==-1) setItemClk(150); // Let's not bother applying the divisor.
27262 2 }
27263
27264
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 if(idat.power==0)
27265 {
27266 1 setSwordClk(0);
27267 1 setItemClk(0);
27268 1 }
27269
27270 2 break;
27271 }
27272
27273
27274 case itype_map:
27275 33 game->lvlitems[dlevel]|=liMAP;
27276 33 break;
27277
27278 case itype_compass:
27279 28 game->lvlitems[dlevel]|=liCOMPASS;
27280 28 break;
27281
27282 case itype_bosskey:
27283 26 game->lvlitems[dlevel]|=liBOSSKEY;
27284 26 break;
27285
27286 case itype_fairy:
27287
27288
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 124 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 71 times.
195 game->set_life(zc_min(game->get_life()+(idat.flags&ITEM_FLAG1 ?(int32_t)(game->get_maxlife()*(idat.misc1/100.0)):((idat.misc1*game->get_hp_per_heart()))),game->get_maxlife()));
27289
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 185 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
195 game->set_magic(zc_min(game->get_magic()+(idat.flags&ITEM_FLAG2 ?(int32_t)(game->get_maxmagic()*(idat.misc2/100.0)):((idat.misc2*game->get_mp_per_block()))),game->get_maxmagic()));
27290 195 break;
27291
27292 case itype_heartpiece:
27293 23 game->change_HCpieces(1);
27294
27295
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 5 times.
23 if(game->get_HCpieces()<game->get_hcp_per_hc())
27296 18 break;
27297
27298 5 game->set_HCpieces(0);
27299
27300 5 getitem(heart_container_id());
27301 5 break;
27302
27303 case itype_killem:
27304 {
27305 if(idat.flags & ITEM_FLAG1) //Active use, not passive
27306 break;
27307 kill_em_all();
27308 sfx(idat.usesound);
27309 }
27310 break;
27311 }
27312
27313 5861 flushItemCache();
27314 5861 update_subscreens();
27315 5861 load_Sitems(&QMisc);
27316 5861 verifyBothWeapons();
27317 5861 }
27318
27319 void takeitem(int32_t id)
27320 {
27321 game->set_item(id, false);
27322 itemdata const& idat = itemsbuf[id];
27323
27324 /* Lower the counters! */
27325 if(idat.count!=-1)
27326 {
27327 if(idat.setmax)
27328 {
27329 game->set_maxcounter(game->get_maxcounter(idat.count)-idat.setmax, idat.count);
27330 }
27331
27332 if(idat.amount&0x3FFF)
27333 {
27334 if(idat.amount&0x8000)
27335 game->set_dcounter(game->get_dcounter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
27336 else game->set_counter(game->get_counter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
27337 }
27338 }
27339
27340 switch(itemsbuf[id&0xFF].family)
27341 {
27342 // NES consistency: replace all flying boomerangs with the current boomerang.
27343 case itype_brang:
27344 if(current_item(itype_brang)) for(int32_t i=0; i<Lwpns.Count(); i++)
27345 {
27346 weapon *w = ((weapon*)Lwpns.spr(i));
27347
27348 if(w->id==wBrang)
27349 {
27350 w->LOADGFX(itemsbuf[current_item_id(itype_brang)].wpn);
27351 }
27352 }
27353
27354 break;
27355
27356 case itype_itmbundle:
27357 {
27358 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
27359 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
27360 for(auto q = 0; q < 10; ++q)
27361 {
27362 if(unsigned(ids[q]) >= MAXITEMS) continue;
27363 takeitem(ids[q]);
27364 }
27365 }
27366 break;
27367
27368 case itype_progressive_itm:
27369 {
27370 int32_t newid = get_progressive_item(idat, true);
27371 if(newid > -1)
27372 takeitem(newid);
27373 }
27374 break;
27375
27376 case itype_heartpiece:
27377 if(game->get_maxlife()>game->get_hp_per_heart())
27378 {
27379 if(game->get_HCpieces()==0)
27380 {
27381 game->set_HCpieces(game->get_hcp_per_hc());
27382 takeitem(iHeartC);
27383 }
27384
27385 game->change_HCpieces(-1);
27386 }
27387 break;
27388
27389 case itype_map:
27390 game->lvlitems[dlevel]&=~liMAP;
27391 break;
27392
27393 case itype_compass:
27394 game->lvlitems[dlevel]&=~liCOMPASS;
27395 break;
27396
27397 case itype_bosskey:
27398 game->lvlitems[dlevel]&=~liBOSSKEY;
27399 break;
27400
27401 case itype_lkey:
27402 if(game->lvlkeys[dlevel]) game->lvlkeys[dlevel]--;
27403 break;
27404
27405 case itype_ring:
27406 if((get_bit(quest_rules,qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
27407 {
27408 ringcolor(false);
27409 }
27410 break;
27411 }
27412 }
27413
27414 // Attempt to pick up an item. (-1 = check items touching Hero.)
27415 3392183 void HeroClass::checkitems(int32_t index)
27416 {
27417 3392183 int32_t tmp=currscr>=128?1:0;
27418
27419
2/2
✓ Branch 0 taken 902 times.
✓ Branch 1 taken 3391281 times.
3392183 if(index==-1)
27420 {
27421
2/2
✓ Branch 0 taken 831608 times.
✓ Branch 1 taken 3391281 times.
4222889 for(auto ind = items.Count()-1; ind >= 0; --ind)
27422 {
27423 831608 item* itm = (item*)items.spr(ind);
27424
2/2
✓ Branch 0 taken 831596 times.
✓ Branch 1 taken 12 times.
831608 if(itm->get_forcegrab())
27425 {
27426 12 checkitems(ind);
27427 12 }
27428 831608 }
27429
2/2
✓ Branch 0 taken 271134 times.
✓ Branch 1 taken 3120147 times.
3391281 if(diagonalMovement)
27430 {
27431 271134 index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,6,6,1);
27432 271134 }
27433 3120147 else index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,1,1,1);
27434 3391281 }
27435
27436
2/2
✓ Branch 0 taken 30088 times.
✓ Branch 1 taken 3362095 times.
3392183 if(index==-1)
27437 3362095 return;
27438
27439 // if (tmpscr[tmp].room==rSHOP && boughtsomething==true)
27440 // return;
27441 30088 item* ptr = (item*)items.spr(index);
27442 30088 int32_t pickup = ptr->pickup;
27443 30088 int8_t exstate = ptr->pickupexstate;
27444 30088 int32_t PriceIndex = ptr->PriceIndex;
27445 30088 int32_t id2 = ptr->id;
27446 30088 int32_t holdid = ptr->id;
27447 30088 int32_t pstr = ptr->pstring;
27448 30088 int32_t pstr_flags = ptr->pickup_string_flags;
27449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30088 times.
30088 if(ptr->fallclk > 0) return; //Don't pick up a falling item
27450
27451
1/2
✓ Branch 0 taken 30088 times.
✗ Branch 1 not taken.
30088 if(itemsbuf[id2].family == itype_progressive_itm)
27452 {
27453 int32_t newid = get_progressive_item(itemsbuf[id2]);
27454 if(newid > -1)
27455 {
27456 id2 = newid;
27457 holdid = newid;
27458 pstr = itemsbuf[newid].pstring;
27459 pstr_flags = itemsbuf[newid].pickup_string_flags;
27460 }
27461 }
27462
27463
2/2
✓ Branch 0 taken 29366 times.
✓ Branch 1 taken 722 times.
30088 bool bottledummy = (pickup&ipCHECK) && tmpscr[tmp].room == rBOTTLESHOP;
27464
27465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30088 times.
30088 if(bottledummy) //Dummy bullshit!
27466 {
27467 if(!game->canFillBottle())
27468 return;
27469 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
27470 {
27471 if(!current_item_power(itype_wallet))
27472 {
27473 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
27474 int32_t tmpprice = -abs(prices[PriceIndex]);
27475 //game->change_drupy(-abs(prices[priceindex]));
27476 int32_t total = game->get_drupy()-tmpprice;
27477 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
27478 game->set_drupy(game->get_drupy()-total);
27479 }
27480 else //infinite wallet
27481 {
27482 game->change_drupy(0);
27483 }
27484 }
27485 boughtsomething=true;
27486 //make the other shop items untouchable after
27487 //you buy something
27488 int32_t count = 0;
27489
27490 for(int32_t i=0; i<3; i++)
27491 {
27492 if(QMisc.bottle_shop_types[tmpscr[tmp].catchall].fill[i] != 0)
27493 {
27494 ++count;
27495 }
27496 }
27497
27498 for(int32_t i=0; i<items.Count(); i++)
27499 {
27500 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
27501 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
27502 }
27503
27504 int32_t slot = game->fillBottle(QMisc.bottle_shop_types[tmpscr[tmp].catchall].fill[PriceIndex]);
27505 id2 = find_bottle_for_slot(slot);
27506 ptr->id = id2;
27507 pstr = 0;
27508 pickup |= ipHOLDUP;
27509 }
27510 else
27511 {
27512 30088 std::vector<int32_t> &ev = FFCore.eventData;
27513 30088 ev.clear();
27514 30088 ev.push_back(id2*10000);
27515 30088 ev.push_back(pickup*10000);
27516 30088 ev.push_back(pstr*10000);
27517 30088 ev.push_back(pstr_flags*10000);
27518 30088 ev.push_back(0);
27519 30088 ev.push_back(ptr->getUID());
27520 30088 ev.push_back(GENEVT_ICTYPE_COLLECT*10000);
27521 30088 ev.push_back(0);
27522
27523 30088 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
27524 30088 bool nullify = ev[4] != 0;
27525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30088 times.
30088 if(nullify) return;
27526 30088 id2 = ev[0]/10000;
27527 30088 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
27528 30088 pstr = ev[2] / 10000;
27529 30088 pstr_flags = ev[3] / 10000;
27530
27531
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30088 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30088 if(itemsbuf[id2].family == itype_bottlefill && !game->canFillBottle())
27532 return; //No picking these up unless you have a bottle to fill!
27533
27534
5/6
✓ Branch 0 taken 28503 times.
✓ Branch 1 taken 1585 times.
✓ Branch 2 taken 25081 times.
✓ Branch 3 taken 3422 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 25081 times.
30088 if(((pickup&ipTIMER) && (ptr->clk2 < 32))&& !(pickup & ipCANGRAB))
27535
2/2
✓ Branch 0 taken 25019 times.
✓ Branch 1 taken 62 times.
25081 if(ptr->id!=iFairyMoving)
27536 // wait for it to stop flashing, doesn't check for other items yet
27537 25019 return;
27538
27539
2/2
✓ Branch 0 taken 5054 times.
✓ Branch 1 taken 15 times.
5069 if(pickup&ipENEMY) // item was being carried by enemy
27540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
30 if(more_carried_items()<=1) // 1 includes this own item.
27541 15 hasitem &= ~2;
27542
27543
2/2
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 4814 times.
5069 if(pickup&ipDUMMY) // dummy item (usually a rupee)
27544 {
27545
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 24 times.
255 if(pickup&ipMONEY)
27546 24 dospecialmoney(index);
27547
27548 255 return;
27549 }
27550
27551
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4814 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4814 if(get_bit(quest_rules,qr_HEARTSREQUIREDFIX) && !canget(id2))
27552 return;
27553
27554 4814 int32_t nextitem = -1;
27555 4814 do
27556 {
27557 4814 nextitem = -1;
27558
4/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4801 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 9 times.
4814 if((itemsbuf[id2].flags & ITEM_COMBINE) && game->get_item(id2))
27559 // Item upgrade routine.
27560 {
27561
27562
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<MAXITEMS; i++)
27563 {
27564 // Find the item which is as close to this item's fam_type as possible.
27565
4/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 2284 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 9 times.
2304 if(itemsbuf[i].family==itemsbuf[id2].family && itemsbuf[i].fam_type>itemsbuf[id2].fam_type
27566
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
20 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
27567 {
27568 9 nextitem = i;
27569 9 }
27570 2304 }
27571
27572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(nextitem>-1)
27573 {
27574 9 id2 = nextitem;
27575
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(get_bit(quest_rules,qr_ITEMCOMBINE_NEW_PSTR))
27576 {
27577 pstr = itemsbuf[id2].pstring;
27578 pstr_flags = itemsbuf[id2].pickup_string_flags;
27579 }
27580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!get_bit(quest_rules,qr_ITEMCOMBINE_CONTINUOUS))
27581 9 break; //no looping
27582 }
27583 }
27584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4805 times.
4805 } while(nextitem > -1);
27585
27586
2/2
✓ Branch 0 taken 4092 times.
✓ Branch 1 taken 722 times.
4814 if(pickup&ipCHECK) // check restrictions
27587
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 562 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 106 times.
722 switch(tmpscr[tmp].room)
27588 {
27589 case rSP_ITEM: // special item
27590
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 1 times.
54 if(!canget(id2)) // These ones always need the Hearts Required check
27591 1 return;
27592
27593 53 break;
27594
27595 case rP_SHOP: // potion shop
27596
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 13 times.
106 if(msg_active)
27597 93 return;
27598 [[fallthrough]];
27599 case rSHOP: // shop
27600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 575 times.
575 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
27601 {
27602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 575 times.
575 if(!current_item_power(itype_wallet))
27603 {
27604
2/2
✓ Branch 0 taken 529 times.
✓ Branch 1 taken 46 times.
575 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
27605 46 int32_t tmpprice = -abs(prices[PriceIndex]);
27606 //game->change_drupy(-abs(prices[priceindex]));
27607 46 int32_t total = game->get_drupy()-tmpprice;
27608 46 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
27609 46 game->set_drupy(game->get_drupy()-total);
27610 46 }
27611 else //infinite wallet
27612 {
27613 game->change_drupy(0);
27614 }
27615 46 }
27616 46 boughtsomething=true;
27617 //make the other shop items untouchable after
27618 //you buy something
27619 46 int32_t count = 0;
27620
27621
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 46 times.
184 for(int32_t i=0; i<3; i++)
27622 {
27623
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 129 times.
138 if(QMisc.shop[tmpscr[tmp].catchall].hasitem[i] != 0)
27624 {
27625 129 ++count;
27626 129 }
27627 138 }
27628
27629
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 46 times.
221 for(int32_t i=0; i<items.Count(); i++)
27630 {
27631
4/4
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 83 times.
175 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
27632 83 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
27633 175 }
27634
27635 46 break;
27636 99 }
27637
27638
2/2
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 3787 times.
4191 if(pickup&ipONETIME) // set mITEM for one-time-only items
27639 {
27640 404 setmapflag(mITEM);
27641
27642 //Okay so having old source files is a godsend. You wanna know why?
27643 //Because the issue here was never to so with the wrong flag being set; no it's always been setting the right flag.
27644 //The problem here is that guy rooms were always checking for getmapflag, which used to have an internal check for the default.
27645 //The default would be mITEM if currscr was under 128 (AKA not in a cave), and mSPECIALITEM if in a cave.
27646 //However, now the check just always defaults to mSPECIALITEM, which causes this bug.
27647 //This means that this section of code is no longer a bunch of eggshells, cause none of these overcomplicated compats actually solved shit lmao - Dimi
27648
27649 /*
27650 // WARNING - Item pickups are very volatile due to crazy compatability hacks, eg., supporting
27651 // broken behavior from early ZC versions. If you change things here please comment on it's purpose.
27652
27653 // some old quests need picking up a screen item to also disable the BELOW flag (for hunger rooms, etc)
27654 // What is etc?! We need to check for every valid state here. ~Gleeok
27655 if(get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW))
27656 {
27657 // Most older quests need one-time-pickups to not remove special items, etc.
27658 if(tmpscr->room==rGRUMBLE)
27659 {
27660 setmapflag(mSPECIALITEM);
27661 }
27662 }
27663 */
27664 404 }
27665
2/2
✓ Branch 0 taken 3596 times.
✓ Branch 1 taken 191 times.
3787 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
27666
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 39 times.
191 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
27667
27668
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4191 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4191 if(exstate > -1 && exstate < 32)
27669 {
27670 setxmapflag(1<<exstate);
27671 }
27672
27673
1/2
✓ Branch 0 taken 4191 times.
✗ Branch 1 not taken.
4191 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
27674 {
27675 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
27676 hidden_entrance(0, true, false, -5);
27677 }
27678
27679 4191 collectitem_script(id2);
27680 4191 getitem(id2, false, true);
27681 }
27682
27683
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 3863 times.
4191 if(pickup&ipHOLDUP)
27684 {
27685 328 attackclk=0;
27686 328 reset_swordcharge();
27687
27688
3/4
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 324 times.
328 if(action!=swimming && !IsSideSwim())
27689 324 reset_hookshot();
27690
27691
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 108 times.
328 if(msg_onscreen)
27692 {
27693 108 dismissmsg();
27694 108 }
27695
27696 328 clear_bitmap(pricesdisplaybuf);
27697
27698
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 328 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
328 if(get_bit(quest_rules, qr_OLDPICKUP) || ((tmpscr[tmp].room==rSP_ITEM || tmpscr[tmp].room==rRP_HC || tmpscr[tmp].room==rTAKEONE) && (pickup&ipONETIME2)) ||
27699 (get_bit(quest_rules, qr_SHOP_ITEMS_VANISH) && (tmpscr[tmp].room==rBOTTLESHOP || tmpscr[tmp].room==rSHOP) && (pickup&ipCHECK)))
27700 {
27701 328 fadeclk=66;
27702 328 }
27703
27704
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 326 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
328 if(id2!=iBombs || action==swimming || get_bit(quest_rules,qr_BOMBHOLDFIX))
27705 {
27706 // don't hold up bombs unless swimming or the bomb hold fix quest rule is on
27707
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 322 times.
326 if(action==swimming)
27708 {
27709 4 action=waterhold1; FFCore.setHeroAction(waterhold1);
27710 4 }
27711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 else if(IsSideSwim())
27712 {
27713 action=sidewaterhold1; FFCore.setHeroAction(sidewaterhold1);
27714 }
27715 else
27716 {
27717 322 action=landhold1; FFCore.setHeroAction(landhold1);
27718 }
27719
27720
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 111 times.
326 if(ptr->twohand)
27721 {
27722
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 110 times.
111 if(action==waterhold1)
27723 {
27724 1 action=waterhold2; FFCore.setHeroAction(waterhold2);
27725 1 }
27726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 else if(action==sidewaterhold1)
27727 {
27728 action=sidewaterhold2; FFCore.setHeroAction(sidewaterhold2);
27729 }
27730 else
27731 {
27732 110 action=landhold2; FFCore.setHeroAction(landhold2);
27733 }
27734 111 }
27735
27736 326 holdclk=130;
27737
27738 //restart music
27739
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 77 times.
326 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0)
27740 77 music_stop();
27741
27742 326 holditem=holdid; // NES consistency: when combining blue potions, hold up the blue potion.
27743 326 freeze_guys=true;
27744 //show the info string
27745
27746
27747 //if (pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || itemsbuf[index].pickup_string_flags&itemdataPSTRING_IP_HOLDUP ) ) )
27748
27749 326 int32_t shop_pstr = 0;
27750
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 57 times.
326 if (PriceIndex > -1)
27751 {
27752
2/3
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
57 switch(tmpscr[tmp].room)
27753 {
27754 case rSHOP:
27755 33 shop_pstr = QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex];
27756 33 break;
27757 case rBOTTLESHOP:
27758 shop_pstr = QMisc.bottle_shop_types[tmpscr[tmp].catchall].str[PriceIndex];
27759 break;
27760 }
27761 57 }
27762
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 326 times.
326 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
27763 {
27764 if ( (pstr > 0 && pstr < msg_count) && ( ( ( pstr_flags&itemdataPSTRING_ALWAYS || pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_IP_HOLDUP || (!(FFCore.GetItemMessagePlayed(id2))) ) ) ) )
27765 {
27766 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
27767 }
27768 else pstr = 0;
27769 if(shop_pstr)
27770 {
27771 donewmsg(shop_pstr);
27772 enqueued_str = pstr;
27773 }
27774 else if(pstr)
27775 {
27776 donewmsg(pstr);
27777 }
27778 }
27779
27780 326 }
27781
27782
3/4
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 293 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
328 if(itemsbuf[id2].family!=itype_triforcepiece || !(itemsbuf[id2].flags & ITEM_GAMEDATA))
27783 {
27784 293 sfx(tmpscr[0].holdupsfx);
27785 293 }
27786
27787 328 ptr->set_forcegrab(false);
27788 328 items.del(index);
27789
27790
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 328 times.
404 for(int32_t i=0; i<Lwpns.Count(); i++)
27791 {
27792 76 weapon *w = (weapon*)Lwpns.spr(i);
27793
27794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(w->dragging==index)
27795 {
27796 w->dragging=-1;
27797 }
27798
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 else if(w->dragging>index)
27799 {
27800 w->dragging-=1;
27801 }
27802 76 }
27803
27804 // clear up shop stuff
27805
4/4
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 188 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 56 times.
328 if((isdungeon()==0)&&(index!=0))
27806 {
27807
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 42 times.
56 if(boughtsomething)
27808 {
27809 42 fadeclk=66;
27810
27811
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
42 if(((item*)items.spr(0))->id == iRupy && ((item*)items.spr(0))->pickup & ipDUMMY)
27812 {
27813 42 items.del(0);
27814
27815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 for(int32_t i=0; i<Lwpns.Count(); i++)
27816 {
27817 weapon *w = (weapon*)Lwpns.spr(i);
27818
27819 if(w->dragging==0)
27820 {
27821 w->dragging=-1;
27822 }
27823 else if(w->dragging>0)
27824 {
27825 w->dragging-=1;
27826 }
27827 }
27828 42 }
27829 42 }
27830
27831
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(msg_onscreen)
27832 {
27833 dismissmsg();
27834 }
27835
27836 56 clear_bitmap(pricesdisplaybuf);
27837 56 set_clip_state(pricesdisplaybuf, 1);
27838 56 }
27839
27840 // items.del(index);
27841 328 }
27842 else
27843 {
27844 3863 ptr->set_forcegrab(false);
27845 3863 items.del(index);
27846
27847
2/2
✓ Branch 0 taken 3628 times.
✓ Branch 1 taken 3863 times.
7491 for(int32_t i=0; i<Lwpns.Count(); i++)
27848 {
27849 3628 weapon *w = (weapon*)Lwpns.spr(i);
27850
27851
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 3595 times.
3628 if(w->dragging==index)
27852 {
27853 33 w->dragging=-1;
27854 33 }
27855
1/2
✓ Branch 0 taken 3595 times.
✗ Branch 1 not taken.
3595 else if(w->dragging>index)
27856 {
27857 w->dragging-=1;
27858 }
27859 3628 }
27860
27861
2/2
✓ Branch 0 taken 3862 times.
✓ Branch 1 taken 1 times.
3863 if(msg_onscreen)
27862 {
27863 1 dismissmsg();
27864 1 }
27865
27866 //general item pickup message
27867 //show the info string
27868 //non-held
27869 //if ( pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(index))) ) ) )
27870
3/6
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 3777 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3863 int32_t shop_pstr = ( tmpscr[tmp].room == rSHOP && PriceIndex>=0 && QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] > 0 ) ? QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] : 0;
27871
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3862 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3862 times.
3863 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
27872 {
27873
6/12
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
1 if ( (pstr > 0 && pstr < msg_count) && ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
27874 {
27875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
27876 1 }
27877 else pstr = 0;
27878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(shop_pstr)
27879 {
27880 donewmsg(shop_pstr);
27881 enqueued_str = pstr;
27882 }
27883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(pstr)
27884 {
27885 1 donewmsg(pstr);
27886 1 }
27887 1 }
27888
27889
27890 3863 clear_bitmap(pricesdisplaybuf);
27891 3863 set_clip_state(pricesdisplaybuf, 1);
27892 }
27893
27894
2/2
✓ Branch 0 taken 4151 times.
✓ Branch 1 taken 40 times.
4191 if(itemsbuf[id2].family==itype_triforcepiece)
27895 {
27896
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 5 times.
40 if(itemsbuf[id2].misc2>0) //Small TF Piece
27897 {
27898 35 getTriforce(id2);
27899 35 }
27900 else
27901 {
27902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (ptr->linked_parent == eeGANON) game->lvlitems[dlevel]|=liBOSS;
27903 5 getBigTri(id2);
27904 }
27905 40 }
27906 3392183 }
27907
27908 126 void HeroClass::StartRefill(int32_t refillWhat)
27909 {
27910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(!refilling)
27911 {
27912 126 refillclk=21;
27913 126 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
27914 126 sfx(WAV_REFILL,128,true);
27915 126 refilling=refillWhat;
27916
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 6 times.
126 if(FFCore.quest_format[vZelda] < 0x255)
27917 {
27918 //Yes, this isn't a QR check. This was implemented before the QRs got bumped up.
27919 //I attempted to change this check to a quest rule, but here's the issue: this affects
27920 //triforces and potions as well, not just fairy flags. This means that having a compat rule
27921 //would result in a rule that is checked by default for every tileset or quest made before
27922 //2.55, one in a place most people won't check. That means that if they were to go to use
27923 //the new potion or triforce flags for jinx curing behavior, they'd find that it doesn't work,
27924 //all because of an obscure compat rule being checked. Most peoples instincts are sadly not
27925 //"go through the compat rules and turn them all off", so this remains a version check instead
27926 //of a qr check. Don't make my mistake and waste time trying to change this in vain. -Deedee
27927 120 Start250Refill(refillWhat);
27928 120 }
27929 else //use 2.55+ behavior
27930 {
27931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(refill_why>=0) // Item index
27932 {
27933 if(itemsbuf[refill_why].family==itype_potion)
27934 {
27935 if(itemsbuf[refill_why].flags & ITEM_FLAG3){swordclk=0;verifyAWpn();}
27936 if(itemsbuf[refill_why].flags & ITEM_FLAG4)itemclk=0;
27937 }
27938 else if(itemsbuf[refill_why].family==itype_triforcepiece)
27939 {
27940 if(itemsbuf[refill_why].flags & ITEM_FLAG3){swordclk=0;verifyAWpn();}
27941 if(itemsbuf[refill_why].flags & ITEM_FLAG4)itemclk=0;
27942 }
27943 }
27944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(refill_why==REFILL_FAIRY)
27945 {
27946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(!get_bit(quest_rules,qr_NONBUBBLEFAIRIES)){swordclk=0;verifyAWpn();}
27947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(get_bit(quest_rules,qr_ITEMBUBBLE))itemclk=0;
27948 6 }
27949 }
27950 126 }
27951 126 }
27952
27953 120 void HeroClass::Start250Refill(int32_t refillWhat)
27954 {
27955
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(!refilling)
27956 {
27957 refillclk=21;
27958 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
27959 sfx(WAV_REFILL,128,true);
27960 refilling=refillWhat;
27961
27962 if(refill_why>=0) // Item index
27963 {
27964 if((itemsbuf[refill_why].family==itype_potion)&&(!get_bit(quest_rules,qr_NONBUBBLEMEDICINE)))
27965 {
27966 swordclk=0;
27967 verifyAWpn();
27968 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
27969 }
27970
27971 if((itemsbuf[refill_why].family==itype_triforcepiece)&&(!get_bit(quest_rules,qr_NONBUBBLETRIFORCE)))
27972 {
27973 swordclk=0;
27974 verifyAWpn();
27975 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
27976 }
27977 }
27978 else if((refill_why==REFILL_FAIRY)&&(!get_bit(quest_rules,qr_NONBUBBLEFAIRIES)))
27979 {
27980 swordclk=0;
27981 verifyAWpn();
27982 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
27983 }
27984 }
27985 120 }
27986
27987 132122 bool HeroClass::refill()
27988 {
27989
4/4
✓ Branch 0 taken 13204 times.
✓ Branch 1 taken 118918 times.
✓ Branch 2 taken 636 times.
✓ Branch 3 taken 12568 times.
132122 if(refilling==REFILL_NONE || refilling==REFILL_FAIRYDONE)
27990 {
27991 119554 return false;
27992 }
27993
27994 12568 ++refillclk;
27995 12568 int32_t speed = get_bit(quest_rules,qr_FASTFILL) ? 6 : 22;
27996 12568 int32_t refill_heart_stop=game->get_maxlife();
27997 12568 int32_t refill_magic_stop=game->get_maxmagic();
27998
27999
4/4
✓ Branch 0 taken 6697 times.
✓ Branch 1 taken 5871 times.
✓ Branch 2 taken 2243 times.
✓ Branch 3 taken 4454 times.
12568 if(refill_why>=0 && itemsbuf[refill_why].family==itype_potion)
28000 {
28001
2/6
✓ Branch 0 taken 4454 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4454 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4454 refill_heart_stop=zc_min(potion_life+(itemsbuf[refill_why].flags & ITEM_FLAG1 ?int32_t(game->get_maxlife()*(itemsbuf[refill_why].misc1 /100.0)):((itemsbuf[refill_why].misc1 *game->get_hp_per_heart()))),game->get_maxlife());
28002
2/6
✓ Branch 0 taken 4454 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4454 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4454 refill_magic_stop=zc_min(potion_magic+(itemsbuf[refill_why].flags & ITEM_FLAG2 ?int32_t(game->get_maxmagic()*(itemsbuf[refill_why].misc2 /100.0)):((itemsbuf[refill_why].misc2 *game->get_mp_per_block()))),game->get_maxmagic());
28003 4454 }
28004
28005
2/2
✓ Branch 0 taken 11536 times.
✓ Branch 1 taken 1032 times.
12568 if(refillclk%speed == 0)
28006 {
28007 // game->life&=0xFFC;
28008
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 571 times.
1032 switch(refill_what)
28009 {
28010 case REFILL_LIFE:
28011
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 433 times.
461 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
28012
28013
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 390 times.
461 if(game->get_life()>=refill_heart_stop)
28014 {
28015 71 game->set_life(refill_heart_stop);
28016 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
28017
2/2
✓ Branch 0 taken 18176 times.
✓ Branch 1 taken 71 times.
18247 for ( int32_t q = 0; q < WAV_COUNT; q++ )
28018 {
28019
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 18105 times.
18176 if ( q == (int32_t)tmpscr->oceansfx ) continue;
28020
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 18104 times.
18105 if ( q == (int32_t)tmpscr->bosssfx ) continue;
28021 18104 stop_sfx(q);
28022 18104 }
28023 71 sfx(QMisc.miscsfx[sfxREFILL]);
28024 71 refilling=REFILL_NONE;
28025 71 return false;
28026 }
28027
28028 390 break;
28029
28030 case REFILL_MAGIC:
28031 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
28032
28033 if(game->get_magic()>=refill_magic_stop)
28034 {
28035 game->set_magic(refill_magic_stop);
28036 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
28037 for ( int32_t q = 0; q < WAV_COUNT; q++ )
28038 {
28039 if ( q == (int32_t)tmpscr->oceansfx ) continue;
28040 if ( q == (int32_t)tmpscr->bosssfx ) continue;
28041 stop_sfx(q);
28042 }
28043 sfx(QMisc.miscsfx[sfxREFILL]);
28044 refilling=REFILL_NONE;
28045 return false;
28046 }
28047
28048 break;
28049
28050 case REFILL_ALL:
28051
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 524 times.
571 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
28052
2/2
✓ Branch 0 taken 559 times.
✓ Branch 1 taken 12 times.
571 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
28053
28054
4/4
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 504 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 12 times.
571 if((game->get_life()>=refill_heart_stop)&&(game->get_magic()>=refill_magic_stop))
28055 {
28056 55 game->set_life(refill_heart_stop);
28057 55 game->set_magic(refill_magic_stop);
28058 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
28059
2/2
✓ Branch 0 taken 14080 times.
✓ Branch 1 taken 55 times.
14135 for ( int32_t q = 0; q < WAV_COUNT; q++ )
28060 {
28061
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 14025 times.
14080 if ( q == (int32_t)tmpscr->oceansfx ) continue;
28062
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14007 times.
14025 if ( q == (int32_t)tmpscr->bosssfx ) continue;
28063 14007 stop_sfx(q);
28064 14007 }
28065 55 sfx(QMisc.miscsfx[sfxREFILL]);
28066 55 refilling=REFILL_NONE;
28067 55 return false;
28068 }
28069
28070 516 break;
28071 }
28072 906 }
28073
28074 12442 return true;
28075 132122 }
28076
28077 35 void HeroClass::getTriforce(int32_t id2)
28078 {
28079
28080 PALETTE flash_pal;
28081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 int32_t refill_frame = ( (itemsbuf[id2].misc5 > 0) ? itemsbuf[id2].misc5 : 88 );
28082
28083
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 35 times.
8995 for(int32_t i=0; i<256; i++)
28084 {
28085
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 7168 times.
8960 flash_pal[i] = get_bit(quest_rules,qr_FADE) ? _RGB(63,63,0) : _RGB(63,63,63);
28086 8960 }
28087
28088
28089
28090 //get rid off all sprites but Hero
28091 35 guys.clear();
28092 35 items.clear();
28093 35 Ewpns.clear();
28094 35 Lwpns.clear();
28095 35 Sitems.clear();
28096 35 chainlinks.clear();
28097
28098 //decorations.clear();
28099
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 17 times.
35 if(!COOLSCROLL)
28100 {
28101 17 show_subscreen_items=false;
28102 17 }
28103
28104 35 sfx(itemsbuf[id2].playsound);
28105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if ( !(itemsbuf[id2].flags & ITEM_FLAG11) ) music_stop();
28106
28107 //If item flag six is enabled, and a sound is set to attributes[2], play that sound.
28108
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if ( (itemsbuf[id2].flags & ITEM_FLAG14) )
28109 {
28110 uint8_t playwav = itemsbuf[id2].misc3;
28111 //zprint2("playwav is: %d\n", playwav);
28112 sfx(playwav);
28113
28114 }
28115
28116 //itemsbuf[id2].flags & ITEM_FLAG9 : Don't dismiss Messages
28117 //itemsbuf[id2].flags & ITEM_FLAG10 : Cutscene interrupts action script..
28118 //itemsbuf[id2].flags & ITEM_FLAG11 : Don't change music.
28119 //itemsbuf[id2].flags & ITEM_FLAG12 : Run Collect Script Script On Collection
28120 //itemsbuf[id2].flags & ITEM_FLAG13 : Run Action Script On Collection
28121 //itemsbuf[id2].flags & ITEM_FLAG14 : Play second sound (WAV) from Attributes[2] (misc2)
28122 //itemsbuf[id2].flags & ITEM_FLAG15 : No MIDI
28123
28124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(!(itemsbuf[id2].flags & ITEM_FLAG15)) //No MIDI flag
28125 {
28126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(itemsbuf[id2].misc1)
28127 jukebox(itemsbuf[id2].misc1+ZC_MIDI_COUNT-1);
28128 else
28129 35 try_zcmusic((char*)moduledata.base_NSF_file,moduledata.tf_track, ZC_MIDI_TRIFORCE);
28130 35 }
28131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
28132 {
28133 35 game->lvlitems[dlevel]|=liTRIFORCE;
28134 35 }
28135
28136 35 int32_t f=0;
28137 35 int32_t x2=0;
28138 35 int32_t curtain_x=0;
28139 35 int32_t c=0;
28140 /*if ( (itemsbuf[id2].flags & ITEM_FLAG12) ) //Run collect script This happens w/o the flag.
28141 {
28142 if(itemsbuf[id2].collect_script && !item_collect_doscript[id2])
28143 {
28144 //clear the item script stack for a new script
28145 ri = &(itemCollectScriptData[id2]);
28146 for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id2][q] = 0xFFFF;
28147 ri->Clear();
28148 //itemCollectScriptData[(id2 & 0xFFF)].Clear();
28149 //for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[(id2 & 0xFFF)][q] = 0;
28150 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, ((id2 & 0xFFF)*-1));
28151 if ( id2 > 0 && !item_collect_doscript[id2] ) //No collect script on item 0.
28152 {
28153 item_collect_doscript[id2] = 1;
28154 itemscriptInitialised[id2] = 0;
28155 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, ((id2)*-1));
28156 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
28157 FFCore.deallocateAllArrays(SCRIPT_ITEM,-(id2));
28158 }
28159 else if (!id2 && !item_collect_doscript[id2]) //item 0
28160 {
28161 item_collect_doscript[id2] = 1;
28162 itemscriptInitialised[id2] = 0;
28163 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, COLLECT_SCRIPT_ITEM_ZERO);
28164 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
28165 FFCore.deallocateAllArrays(SCRIPT_ITEM,COLLECT_SCRIPT_ITEM_ZERO);
28166 }
28167 }
28168 }
28169 */
28170 35 do
28171 {
28172
28173
28174
1/2
✓ Branch 0 taken 18981 times.
✗ Branch 1 not taken.
18981 if ( (itemsbuf[id2].flags & ITEM_FLAG13) ) //Run action script on collection.
28175 {
28176 if ( itemsbuf[id2].script )
28177 {
28178 if ( !item_doscript[id2] )
28179 {
28180 ri = &(itemScriptData[id2]);
28181 for ( int32_t q = 0; q < 1024; q++ ) item_stack[id2][q] = 0xFFFF;
28182 ri->Clear();
28183 item_doscript[id2] = 1;
28184 itemscriptInitialised[id2] = 0;
28185 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].script, id2);
28186 FFCore.deallocateAllArrays(SCRIPT_ITEM,(id2));
28187 }
28188 else
28189 {
28190 if ( !(itemsbuf[id2].flags & ITEM_FLAG10) ) //Cutscene halts the script it resumes after cutscene.
28191 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].script, id2); //if flag is off, run the script every frame of the cutscene.
28192 }
28193 }
28194 }
28195 //if ( itemsbuf[id2].misc2 == 2 ) //No cutscene; what if people used '2' on older quests?
28196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18981 times.
18981 if ( (itemsbuf[id2].flags & ITEM_FLAG12) ) //No cutscene
28197 {
28198 return;
28199 }
28200
2/2
✓ Branch 0 taken 18946 times.
✓ Branch 1 taken 35 times.
18981 if(f==40)
28201 {
28202 35 actiontype oldaction = action;
28203 35 ALLOFF((!(itemsbuf[id2].flags & ITEM_FLAG9)), false);
28204 35 action=oldaction; // have to reset this flag
28205 35 FFCore.setHeroAction(oldaction);
28206 35 }
28207
28208
28209
4/4
✓ Branch 0 taken 17581 times.
✓ Branch 1 taken 1400 times.
✓ Branch 2 taken 15901 times.
✓ Branch 3 taken 1680 times.
18981 if(f>=40 && f<88)
28210 {
28211
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 1344 times.
1680 if(get_bit(quest_rules,qr_FADE))
28212 {
28213 //int32_t flashbit = ;
28214
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 336 times.
✓ Branch 2 taken 252 times.
✓ Branch 3 taken 84 times.
336 if((f&(((get_bit(quest_rules,qr_EPILEPSY) || epilepsyFlashReduction)) ? 6 : 3))==0)
28215 {
28216 84 fade_interpolate(RAMpal,flash_pal,RAMpal,42,0,CSET(6)-1);
28217 84 refreshpal=true;
28218 84 }
28219
28220
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 84 times.
336 if((f&3)==2)
28221 {
28222 84 loadpalset(0,0);
28223 84 loadpalset(1,1);
28224 84 loadpalset(5,5);
28225
28226
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
28227 12 else loadlvlpal(0xB); // TODO: Cave/Item Cellar distinction?
28228 84 }
28229 336 }
28230 else
28231 {
28232
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 168 times.
1344 if((f&((get_bit(quest_rules,qr_EPILEPSY)) ? 10 : 7))==0)
28233 {
28234
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 168 times.
672 for(int32_t cs2=2; cs2<5; cs2++)
28235 {
28236
2/2
✓ Branch 0 taken 7560 times.
✓ Branch 1 taken 504 times.
8064 for(int32_t i=1; i<16; i++)
28237 {
28238 7560 RAMpal[CSET(cs2)+i]=flash_pal[CSET(cs2)+i];
28239 7560 }
28240 504 }
28241
28242 168 refreshpal=true;
28243 168 }
28244
28245
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 168 times.
1344 if((f&7)==4)
28246 {
28247
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
28248 else loadlvlpal(0xB);
28249
28250 168 loadpalset(5,5);
28251 168 }
28252 }
28253 1680 }
28254
28255
28256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18981 times.
18981 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
28257 {
28258
2/2
✓ Branch 0 taken 18946 times.
✓ Branch 1 taken 35 times.
18981 if(f==refill_frame)
28259 {
28260 35 refill_what=REFILL_ALL;
28261 35 refill_why=id2;
28262 35 StartRefill(REFILL_ALL);
28263 35 refill();
28264 35 }
28265
28266
2/2
✓ Branch 0 taken 16765 times.
✓ Branch 1 taken 2216 times.
18981 if(f==(refill_frame+1))
28267 {
28268
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 2181 times.
2216 if(refill())
28269 {
28270 2181 --f;
28271 2181 }
28272 2216 }
28273 18981 }
28274
28275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18981 times.
18981 if(itemsbuf[id2].flags & ITEM_FLAG1) // Warp out flag
28276 {
28277
4/4
✓ Branch 0 taken 9520 times.
✓ Branch 1 taken 9461 times.
✓ Branch 2 taken 6720 times.
✓ Branch 3 taken 2800 times.
18981 if(f>=208 && f<288)
28278 {
28279 2800 ++x2;
28280
28281
3/3
✓ Branch 0 taken 1120 times.
✓ Branch 1 taken 1120 times.
✓ Branch 2 taken 560 times.
2800 switch(++c)
28282 {
28283 case 5:
28284 560 c=0;
28285 [[fallthrough]];
28286 case 0:
28287 case 2:
28288 case 3:
28289 1680 ++x2;
28290 1680 break;
28291 }
28292 2800 }
28293
28294 18981 do_dcounters();
28295
28296
2/2
✓ Branch 0 taken 6720 times.
✓ Branch 1 taken 12261 times.
18981 if(f<288)
28297 {
28298 12261 curtain_x=x2&0xF8;
28299 12261 draw_screen_clip_rect_x1=curtain_x;
28300 12261 draw_screen_clip_rect_x2=255-curtain_x;
28301 12261 draw_screen_clip_rect_y1=0;
28302 12261 draw_screen_clip_rect_y2=223;
28303 //draw_screen(tmpscr);
28304 12261 }
28305 18981 }
28306
28307 18981 draw_screen(tmpscr);
28308 //this causes bugs
28309 //the subscreen appearing over the curtain effect should now be fixed in draw_screen
28310 //so this is not necessary -DD
28311 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,false);
28312
28313 //Run Triforce Script
28314 18981 advanceframe(true);
28315 18981 ++f;
28316
2/2
✓ Branch 0 taken 18946 times.
✓ Branch 1 taken 35 times.
37962 }
28317 while
28318 (
28319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18981 times.
18981 (f < ( (itemsbuf[id2].misc4 > 0) ? itemsbuf[id2].misc4 : 408))
28320
4/6
✓ Branch 0 taken 2555 times.
✓ Branch 1 taken 16426 times.
✓ Branch 2 taken 2555 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2555 times.
18981 || (!(itemsbuf[id2].flags & ITEM_FLAG15) /*&& !(itemsbuf[id2].flags & ITEM_FLAG11)*/ && (midi_pos > 0 && !replay_is_active()))
28321
4/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 2555 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2555 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2409 times.
✓ Branch 7 taken 146 times.
5110 || (/*!(itemsbuf[id2].flags & ITEM_FLAG15) &&*/ !(itemsbuf[id2].flags & ITEM_FLAG11) && (zcmusic!=NULL) && (zcmusic->position<800 && !replay_is_active())
28322 // Music is played at the same speed when fps is uncapped, so in replay mode we need to ignore the music position and instead
28323 // just count frames. 480 is the number of frames it takes for the triforce song in classic_1st.qst to finish playing, but the exact
28324 // value doesn't matter.
28325
2/4
✓ Branch 0 taken 2409 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2555 times.
2555 || (replay_is_active() && f < 480) )
28326 ); // 800 may not be just right, but it works
28327
28328 35 action=none; FFCore.setHeroAction(none);
28329 35 holdclk=0;
28330 35 draw_screen_clip_rect_x1=0;
28331 35 draw_screen_clip_rect_x2=255;
28332 35 draw_screen_clip_rect_y1=0;
28333 35 draw_screen_clip_rect_y2=223;
28334 35 show_subscreen_items=true;
28335
28336 //Warp Hero out of item cellars, in 2.10 and earlier quests. -Z ( 16th January, 2019 )
28337 //Added a QR for this, to Other->2, as `Triforce in Cellar Warps Hero Out`. -Z 15th March, 2019
28338
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
35 if(itemsbuf[id2].flags & ITEM_FLAG1 && ( get_bit(quest_rules,qr_SIDEVIEWTRIFORCECELLAR) ? ( currscr < MAPSCRS192b136 ) : (currscr < MAPSCRSNORMAL) ) )
28339 {
28340 36 sdir=dir;
28341 36 dowarp(1,0); //side warp
28342 36 }
28343 else
28344 {
28345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( !(itemsbuf[id2].flags & ITEM_FLAG11) ) playLevelMusic();
28346 }
28347 35 }
28348
28349 111 void red_shift()
28350 {
28351 111 int32_t tnum=176;
28352
28353 // set up the new palette
28354
2/2
✓ Branch 0 taken 3552 times.
✓ Branch 1 taken 111 times.
3663 for(int32_t i=CSET(2); i < CSET(4); i++)
28355 {
28356 3552 int32_t r = (i-CSET(2)) << 1;
28357 3552 RAMpal[i+tnum].r = r;
28358 3552 RAMpal[i+tnum].g = r >> 3;
28359 3552 RAMpal[i+tnum].b = r >> 4;
28360 3552 }
28361
28362 // color scale the game screen
28363
2/2
✓ Branch 0 taken 18648 times.
✓ Branch 1 taken 111 times.
18759 for(int32_t y=0; y<168; y++)
28364 {
28365
2/2
✓ Branch 0 taken 4773888 times.
✓ Branch 1 taken 18648 times.
4792536 for(int32_t x=0; x<256; x++)
28366 {
28367 4773888 int32_t c = framebuf->line[y+playing_field_offset][x];
28368
2/2
✓ Branch 0 taken 2583169 times.
✓ Branch 1 taken 2190719 times.
4773888 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
28369
1/2
✓ Branch 0 taken 4773888 times.
✗ Branch 1 not taken.
4773888 framebuf->line[y+playing_field_offset][x] = (c ? (r+tnum+CSET(2)) : 0);
28370 4773888 }
28371 18648 }
28372
28373 111 refreshpal = true;
28374 111 }
28375
28376
28377
28378 void setup_red_screen_old()
28379 {
28380 clear_bitmap(framebuf);
28381 rectfill(scrollbuf, 0, 0, 255, 167, 0);
28382
28383 if(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, tmpscr, 0, playing_field_offset, 2);
28384
28385 if(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, tmpscr, 0, playing_field_offset, 2);
28386
28387 putscr(scrollbuf, 0, 0, tmpscr);
28388 putscrdoors(scrollbuf,0,0,tmpscr);
28389 blit(scrollbuf, framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28390 do_layer(framebuf, 0, 1, tmpscr, 0, 0, 2);
28391
28392 if(!(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, tmpscr, 0, 0, 2);
28393
28394 do_layer(framebuf, -2, 0, tmpscr, 0, 0, 2);
28395 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
28396 {
28397 do_layer(framebuf, -2, 1, tmpscr, 0, 0, 2);
28398 do_layer(framebuf, -2, 2, tmpscr, 0, 0, 2);
28399 }
28400
28401 if(!(msg_bg_display_buf->clip))
28402 {
28403 blit_msgstr_bg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28404 }
28405
28406 if(!(msg_portrait_display_buf->clip))
28407 {
28408 blit_msgstr_prt(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28409 }
28410
28411 if(!(msg_txt_display_buf->clip))
28412 {
28413 blit_msgstr_fg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28414 }
28415
28416 if(!(pricesdisplaybuf->clip))
28417 {
28418 masked_blit(pricesdisplaybuf, framebuf,0,0,0,playing_field_offset, 256,168);
28419 }
28420
28421 //red shift
28422 // color scale the game screen
28423 for(int32_t y=0; y<168; y++)
28424 {
28425 for(int32_t x=0; x<256; x++)
28426 {
28427 int32_t c = framebuf->line[y+playing_field_offset][x];
28428 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
28429 framebuf->line[y+playing_field_offset][x] = (c ? (r+CSET(2)) : 0);
28430 }
28431 }
28432
28433 // Hero->draw(framebuf);
28434 blit(framebuf,scrollbuf, 0, playing_field_offset, 256, playing_field_offset, 256, 168);
28435
28436 clear_bitmap(framebuf);
28437
28438 if(!((tmpscr->layermap[2]==0||(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)))
28439 && tmpscr->layermap[3]==0
28440 && tmpscr->layermap[4]==0
28441 && tmpscr->layermap[5]==0
28442 && !overheadcombos(tmpscr)))
28443 {
28444 if(!(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, tmpscr, 0, 0, 2);
28445
28446 do_layer(framebuf, 0, 4, tmpscr, 0, 0, 2);
28447 do_layer(framebuf, -1, 0, tmpscr, 0, 0, 2);
28448 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
28449 {
28450 do_layer(framebuf, -1, 1, tmpscr, 0, 0, 2);
28451 do_layer(framebuf, -1, 2, tmpscr, 0, 0, 2);
28452 }
28453 do_layer(framebuf, 0, 5, tmpscr, 0, 0, 2);
28454 do_layer(framebuf, 0, 6, tmpscr, 0, 0, 2);
28455
28456 //do an AND masked blit for messages on top of layers
28457 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(pricesdisplaybuf->clip) || !(msg_portrait_display_buf->clip))
28458 {
28459 BITMAP* subbmp = create_bitmap_ex(8,256,168);
28460 clear_bitmap(subbmp);
28461 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(msg_portrait_display_buf->clip))
28462 {
28463 masked_blit(framebuf, subbmp, 0, playing_field_offset, 0, 0, 256, 168);
28464 if(!(msg_bg_display_buf->clip)) blit_msgstr_bg(subbmp, 0, 0, 0, 0, 256, 168);
28465 if(!(msg_portrait_display_buf->clip)) blit_msgstr_prt(subbmp, 0, 0, 0, 0, 256, 168);
28466 if(!(msg_txt_display_buf->clip)) blit_msgstr_fg(subbmp, 0, 0, 0, 0, 256, 168);
28467 }
28468 for(int32_t y=0; y<168; y++)
28469 {
28470 for(int32_t x=0; x<256; x++)
28471 {
28472 int32_t c1 = framebuf->line[y+playing_field_offset][x];
28473 int32_t c2 = subbmp->line[y][x];
28474 int32_t c3 = pricesdisplaybuf->clip ? 0 : pricesdisplaybuf->line[y][x];
28475
28476 if(c1 && c3)
28477 {
28478 framebuf->line[y+playing_field_offset][x] = c3;
28479 }
28480 else if(c1 && c2)
28481 {
28482 framebuf->line[y+playing_field_offset][x] = c2;
28483 }
28484 }
28485 }
28486 destroy_bitmap(subbmp);
28487 }
28488
28489 //red shift
28490 // color scale the game screen
28491 for(int32_t y=0; y<168; y++)
28492 {
28493 for(int32_t x=0; x<256; x++)
28494 {
28495 int32_t c = framebuf->line[y+playing_field_offset][x];
28496 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
28497 framebuf->line[y+playing_field_offset][x] = r+CSET(2);
28498 }
28499 }
28500 }
28501
28502 blit(framebuf,scrollbuf, 0, playing_field_offset, 0, playing_field_offset, 256, 168);
28503
28504 // set up the new palette
28505 for(int32_t i=CSET(2); i < CSET(4); i++)
28506 {
28507 int32_t r = (i-CSET(2)) << 1;
28508 RAMpal[i].r = r;
28509 RAMpal[i].g = r >> 3;
28510 RAMpal[i].b = r >> 4;
28511 }
28512
28513 refreshpal = true;
28514 }
28515
28516
28517
28518 60 void slide_in_color(int32_t color)
28519 {
28520
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 60 times.
360 for(int32_t i=1; i<16; i+=3)
28521 {
28522 300 RAMpal[CSET(2)+i+2] = RAMpal[CSET(2)+i+1];
28523 300 RAMpal[CSET(2)+i+1] = RAMpal[CSET(2)+i];
28524 300 RAMpal[CSET(2)+i] = NESpal(color);
28525 300 }
28526
28527 60 refreshpal=true;
28528 60 }
28529
28530
28531 14 void HeroClass::heroDeathAnimation()
28532 {
28533 14 int32_t f=0;
28534 14 int32_t deathclk=0,deathfrm=0;
28535
28536 14 action=none; FFCore.setHeroAction(dying); //mayhaps a new action of 'gameover'? -Z
28537
28538 14 kill_sfx(); //call before the onDeath script.
28539
28540 //do
28541 //{
28542
28543 // ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH, SCRIPT_PLAYER_DEATH);
28544 // FFCore.Waitframe();
28545 //}while(player_doscript);
28546 //ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH, SCRIPT_PLAYER_DEATH);
28547 //while(player_doscript) { advanceframe(true); } //Not safe. The script runs for only one frame at present.
28548
28549 //Playing=false;
28550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!debug_enabled)
28551 {
28552 14 Paused=false;
28553 14 }
28554
28555 /*
28556 game->set_deaths(zc_min(game->get_deaths()+1,999));
28557 dir=down;
28558 music_stop();
28559
28560 attackclk=hclk=superman=0;
28561 scriptcoldet = 1;
28562
28563 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
28564
28565
28566
28567 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
28568 quakeclk=wavy=0;
28569
28570 //in original Z1, Hero marker vanishes at death.
28571 //code in subscr.cpp, put_passive_subscr checks the following value.
28572 //color 255 is a GUI color, so quest makers shouldn't be using this value.
28573 //Also, subscreen is static after death in Z1.
28574 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
28575 QMisc.colors.hero_dot = 255;
28576 //doesn't work
28577 //scrollbuf is tampered with by draw_screen()
28578 //put_passive_subscr(scrollbuf, &QMisc, 256, passive_subscreen_offset, false, false);//save this and reuse it.
28579 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
28580 clear_bitmap(subscrbmp);
28581 put_passive_subscr(subscrbmp, &QMisc, 0, passive_subscreen_offset, false, sspUP);
28582 QMisc.colors.hero_dot = tmp_hero_dot;
28583 */
28584 14 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
28585 14 clear_bitmap(subscrbmp);
28586 //get rid off all sprites but Hero
28587 14 guys.clear();
28588 14 items.clear();
28589 14 Ewpns.clear();
28590 14 Lwpns.clear();
28591 14 Sitems.clear();
28592 14 chainlinks.clear();
28593 14 decorations.clear();
28594 14 Playing = false;
28595
28596
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 game->set_deaths(zc_min(game->get_deaths()+1,USHRT_MAX));
28597 14 dir=down;
28598 14 music_stop();
28599
28600 14 attackclk=hclk=superman=0;
28601 14 scriptcoldet = 1;
28602
28603
2/2
✓ Branch 0 taken 448 times.
✓ Branch 1 taken 14 times.
462 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
28604
28605
28606
28607 14 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
28608 14 quakeclk=wavy=0;
28609
28610 //in original Z1, Hero marker vanishes at death.
28611 //code in subscr.cpp, put_passive_subscr checks the following value.
28612 //color 255 is a GUI color, so quest makers shouldn't be using this value.
28613 //Also, subscreen is static after death in Z1.
28614 14 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
28615 14 QMisc.colors.hero_dot = 255;
28616 //doesn't work
28617 //scrollbuf is tampered with by draw_screen()
28618 //put_passive_subscr(scrollbuf, &QMisc, 256, passive_subscreen_offset, false, false);//save this and reuse it.
28619
28620 14 put_passive_subscr(subscrbmp, &QMisc, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
28621 //Don't forget passive subscreen scripts!
28622
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 if(get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
28623 {
28624 1 script_drawing_commands.Clear(); //We only want draws from this script
28625
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(DMaps[currdmap].passive_sub_script != 0)
28626 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
28627
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(passive_subscreen_waitdraw && DMaps[currdmap].passive_sub_script != 0 && passive_subscreen_doscript != 0)
28628 {
28629 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
28630 passive_subscreen_waitdraw = false;
28631 }
28632 1 BITMAP* tmp = framebuf;
28633 1 framebuf = subscrbmp; //Hack; force draws to subscrbmp
28634 1 do_script_draws(framebuf, tmpscr, 0, playing_field_offset); //Draw the script draws
28635 1 framebuf = tmp;
28636 1 script_drawing_commands.Clear(); //Don't let these draws repeat during 'draw_screen()'
28637 1 }
28638 14 QMisc.colors.hero_dot = tmp_hero_dot;
28639 14 bool clearedit = false;
28640 14 do
28641 {
28642 //if ( player_doscript )
28643 //{
28644 // ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_WIN, SCRIPT_PLAYER_WIN);
28645 //if ( f ) --f;
28646 // load_control_state(); //goto adv;
28647 //}
28648 //else
28649 //{
28650 // if ( !clearedit )
28651 // {
28652
28653
28654 // clearedit = true;
28655
28656 // }
28657 //}
28658 //else Playing = false;
28659
2/2
✓ Branch 0 taken 3352 times.
✓ Branch 1 taken 1287 times.
4639 if(f<254)
28660 {
28661
2/2
✓ Branch 0 taken 2890 times.
✓ Branch 1 taken 462 times.
3352 if(f<=32)
28662 {
28663 462 hclk=(32-f);
28664 462 }
28665
28666
4/4
✓ Branch 0 taken 2496 times.
✓ Branch 1 taken 856 times.
✓ Branch 2 taken 1508 times.
✓ Branch 3 taken 988 times.
3352 if(f>=62 && f<138)
28667 {
28668
5/5
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 52 times.
✓ Branch 4 taken 52 times.
988 switch((f-62)%20)
28669 {
28670 case 0:
28671 52 dir=right;
28672 52 break;
28673
28674 case 5:
28675 52 dir=up;
28676 52 break;
28677
28678 case 10:
28679 52 dir=left;
28680 52 break;
28681
28682 case 15:
28683 52 dir=down;
28684 52 break;
28685 }
28686
28687 988 herostep();
28688 988 }
28689
28690
4/4
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 2572 times.
✓ Branch 2 taken 598 times.
✓ Branch 3 taken 182 times.
3352 if(f>=194 && f<208)
28691 {
28692
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 13 times.
182 if(f==194)
28693 {
28694 13 action=dying;
28695 13 FFCore.setHeroAction(dying);
28696 13 }
28697
28698 182 extend = 0;
28699 182 cs = wpnsbuf[spr_death].csets&15;
28700 182 tile = wpnsbuf[spr_death].tile;
28701
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS))
28702 {
28703 tile += deathfrm;
28704 f = 206;
28705 if(++deathclk >= wpnsbuf[spr_death].speed)
28706 {
28707 deathclk=0;
28708 if(++deathfrm >= wpnsbuf[spr_death].frames)
28709 {
28710 f = 208;
28711 deathfrm = 0;
28712 }
28713 }
28714 }
28715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 182 times.
182 else if(BSZ)
28716 {
28717 tile += (f-194)/3;
28718 }
28719
2/2
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 52 times.
182 else if(f>=204)
28720 {
28721 52 ++tile;
28722 52 }
28723 182 }
28724
28725
2/2
✓ Branch 0 taken 3339 times.
✓ Branch 1 taken 13 times.
3352 if(f==208)
28726 {
28727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if ( dontdraw < 2 ) { dontdraw = 1; }
28728 13 }
28729
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 3048 times.
3352 if(get_bit(quest_rules,qr_FADE))
28730 {
28731
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 84 times.
304 if(f < 170)
28732 {
28733
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 110 times.
220 if(f<60)
28734 {
28735 110 draw_screen(tmpscr);
28736 //reuse our static subscreen
28737 110 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
28738 110 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28739 110 }
28740
28741
2/2
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 1 times.
220 if(f==60)
28742 {
28743 1 red_shift();
28744 1 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
28745 1 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
28746 1 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
28747
28748
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for(int32_t q=0; q<PAL_SIZE; q++)
28749 {
28750 256 trans_table2.data[0][q] = q;
28751 256 trans_table2.data[q][q] = q;
28752 256 }
28753 1 }
28754
28755
3/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
220 if(f>=60 && f<=169)
28756 {
28757 110 draw_screen(tmpscr);
28758 //reuse our static subscreen
28759 110 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28760 110 red_shift();
28761
28762 110 }
28763
28764
3/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 189 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
220 if(f>=139 && f<=169)//fade from red to black
28765 {
28766 31 fade_interpolate(RAMpal,black_palette,RAMpal, (f-138)<<1, 224, 255);
28767 31 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
28768 31 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
28769 31 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
28770
28771
2/2
✓ Branch 0 taken 7936 times.
✓ Branch 1 taken 31 times.
7967 for(int32_t q=0; q<PAL_SIZE; q++)
28772 {
28773 7936 trans_table2.data[0][q] = q;
28774 7936 trans_table2.data[q][q] = q;
28775 7936 }
28776
28777 31 refreshpal=true;
28778 31 }
28779 220 }
28780 else //f>=170
28781 {
28782
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 1 times.
84 if(f==170)//make Hero grayish
28783 {
28784 1 fade_interpolate(RAMpal,black_palette,RAMpal,64, 224, 255);
28785
28786
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1 times.
17 for(int32_t i=CSET(6); i < CSET(7); i++)
28787 {
28788 16 int32_t g = (RAMpal[i].r + RAMpal[i].g + RAMpal[i].b)/3;
28789 16 RAMpal[i] = _RGB(g,g,g);
28790 16 }
28791
28792 1 refreshpal = true;
28793 1 }
28794
28795 //draw only hero. otherwise black layers might cover him.
28796 84 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
28797 84 draw(framebuf);
28798 84 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28799 }
28800 304 }
28801 else //!qr_FADE
28802 {
28803
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==58)
28804 {
28805
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 12 times.
1164 for(int32_t i = 0; i < 96; i++)
28806 1152 tmpscr->cset[i] = 3;
28807
28808
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 for(int32_t j=0; j<6; j++)
28809
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 70 times.
74 if(tmpscr->layermap[j]>0)
28810
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 2 times.
194 for(int32_t i=0; i<96; i++)
28811 194 tmpscr2[j].cset[i] = 3;
28812 12 }
28813
28814
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==59)
28815 {
28816
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 12 times.
972 for(int32_t i = 96; i < 176; i++)
28817 960 tmpscr->cset[i] = 3;
28818
28819
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 for(int32_t j=0; j<6; j++)
28820
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 70 times.
74 if(tmpscr->layermap[j]>0)
28821
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 2 times.
162 for(int32_t i=96; i<176; i++)
28822 162 tmpscr2[j].cset[i] = 3;
28823 12 }
28824
28825
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==60)
28826 {
28827
2/2
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
2124 for(int32_t i=0; i<176; i++)
28828 {
28829 2112 tmpscr->cset[i] = 2;
28830 2112 }
28831
28832
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 for(int32_t j=0; j<6; j++)
28833
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 70 times.
74 if(tmpscr->layermap[j]>0)
28834
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 2 times.
354 for(int32_t i=0; i<176; i++)
28835 354 tmpscr2[j].cset[i] = 2;
28836
28837
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 12 times.
72 for(int32_t i=1; i<16; i+=3)
28838 {
28839 60 RAMpal[CSET(2)+i] = NESpal(0x17);
28840 60 RAMpal[CSET(2)+i+1] = NESpal(0x16);
28841 60 RAMpal[CSET(2)+i+2] = NESpal(0x26);
28842 60 }
28843
28844 12 refreshpal=true;
28845 12 }
28846
28847
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==139)
28848 12 slide_in_color(0x06);
28849
28850
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==149)
28851 12 slide_in_color(0x07);
28852
28853
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==159)
28854 12 slide_in_color(0x0F);
28855
28856
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==169)
28857 {
28858 12 slide_in_color(0x0F);
28859 12 slide_in_color(0x0F);
28860 12 }
28861
28862
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==170)
28863 {
28864
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 12 times.
72 for(int32_t i=1; i<16; i+=3)
28865 {
28866 60 RAMpal[CSET(6)+i] = NESpal(0x10);
28867 60 RAMpal[CSET(6)+i+1] = NESpal(0x30);
28868 60 RAMpal[CSET(6)+i+2] = NESpal(0x00);
28869 60 refreshpal = true;
28870 60 }
28871 12 }
28872
28873
2/2
✓ Branch 0 taken 2028 times.
✓ Branch 1 taken 1020 times.
3048 if(f < 169)
28874 {
28875 2028 draw_screen(tmpscr);
28876 //reuse our static subscreen
28877 2028 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28878 2028 }
28879 else
28880 {
28881 //draw only hero. otherwise black layers might cover him.
28882 1020 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
28883 1020 draw(framebuf);
28884 1020 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28885 }
28886 }
28887 3352 }
28888
28889
2/2
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 39 times.
1287 else if(f<350)//draw 'GAME OVER' text
28890 {
28891
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1248 if(get_bit(quest_rules, qr_INSTANT_RESPAWN) && !get_bit(quest_rules, qr_INSTANT_CONTINUE))
28892 {
28893 Quit = qRELOAD;
28894 skipcont = 1;
28895 clear_bitmap(framebuf);
28896 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28897 }
28898
2/4
✓ Branch 0 taken 1248 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1248 times.
1248 else if(!get_bit(quest_rules, qr_INSTANT_RESPAWN) && get_bit(quest_rules, qr_INSTANT_CONTINUE))
28899 {
28900 Quit = qCONT;
28901 skipcont = 1;
28902 clear_bitmap(framebuf);
28903 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28904 }
28905 else
28906 {
28907 1248 clear_to_color(framebuf,SaveScreenSettings[SAVESC_BACKGROUND]);
28908 1248 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28909 1248 textout_ex(framebuf,zfont,"GAME OVER",96,playing_field_offset+80,SaveScreenSettings[SAVESC_TEXT],-1);
28910 }
28911 1248 }
28912 else
28913 {
28914 39 clear_bitmap(framebuf);
28915 }
28916
28917 //SFX... put them all here
28918
4/4
✓ Branch 0 taken 4599 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 13 times.
4639 switch(f)
28919 {
28920 case 0:
28921 14 sfx(getHurtSFX(),pan(x.getInt()));
28922 14 break;
28923 //Death sound.
28924 case 60:
28925 13 sfx(WAV_SPIRAL);
28926 13 break;
28927 //Message sound.
28928 case 194:
28929 13 sfx(WAV_MSG);
28930 13 break;
28931 }
28932 //adv:
28933 4639 advanceframe(true);
28934 4639 ++f;
28935 //if (!player_doscript ) ++f;
28936
2/2
✓ Branch 0 taken 4625 times.
✓ Branch 1 taken 14 times.
9278 }
28937
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4626 times.
4639 while(f<353 && !Quit);
28938
28939 14 destroy_bitmap(subscrbmp);
28940 14 action=none; FFCore.setHeroAction(none);
28941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if ( dontdraw < 2 ) { dontdraw=0; }
28942 14 }
28943
28944
28945 5 void HeroClass::ganon_intro()
28946 {
28947 /*
28948 ************************
28949 * GANON INTRO SEQUENCE *
28950 ************************
28951 -25 DOT updates
28952 -24 HERO in
28953 0 TRIFORCE overhead - code begins at this point (f == 0)
28954 47 GANON in
28955 58 LIGHT step
28956 68 LIGHT step
28957 78 LIGHT step
28958 255 TRIFORCE out
28959 256 TRIFORCE in
28960 270 TRIFORCE out
28961 271 GANON out, HERO face up
28962 */
28963 5 loaded_guys=true;
28964 5 loaditem();
28965
28966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(game->lvlitems[dlevel]&liBOSS)
28967 {
28968 return;
28969 }
28970
28971 5 dir=down;
28972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if ( !isSideViewHero() )
28973 {
28974 5 fall = 0; //Fix midair glitch on holding triforce. -Z
28975 5 fakefall = 0;
28976 5 z = 0;
28977 5 fakez = 0;
28978 5 }
28979 5 action=landhold2; FFCore.setHeroAction(landhold2);
28980 5 holditem=getItemID(itemsbuf,itype_triforcepiece, 1);
28981 //not good, as this only returns the highest level that Hero possesses. -DD
28982 //getHighestLevelOfFamily(game, itemsbuf, itype_triforcepiece, false));
28983
28984
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1205 times.
✓ Branch 2 taken 1205 times.
✓ Branch 3 taken 5 times.
1210 for(int32_t f=0; f<271 && !Quit; f++)
28985 {
28986
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 5 times.
1205 if(f==47)
28987 {
28988 5 music_stop();
28989 5 stop_sfx(WAV_ROAR);
28990 5 sfx(WAV_GASP);
28991 5 sfx(WAV_GANON);
28992 5 int32_t Id=0;
28993
28994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 for(int32_t i=0; i<eMAXGUYS; i++)
28995 {
28996
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 5 times.
395 if(guysbuf[i].flags2&eneflag_ganon)
28997 {
28998 5 Id=i;
28999 5 break;
29000 }
29001 390 }
29002
29003
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 if(current_item(itype_ring))
29004 {
29005 4 addenemy(160,96,Id,0);
29006 4 }
29007 else
29008 {
29009 1 addenemy(80,32,Id,0);
29010 }
29011 5 }
29012
29013
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 5 times.
1205 if(f==48)
29014 {
29015 5 lighting(true,true); // Hmm. -L
29016 5 f += 30;
29017 5 }
29018
29019 //NES Z1, the triforce vanishes for one frame in two cases
29020 //while still showing Hero's two-handed overhead sprite.
29021 //This should be a Quest Rule for NES Accuracy. -Z
29022
4/4
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 1195 times.
1205 if(f==255 || f==270)
29023 {
29024 10 holditem=-1;
29025 10 }
29026
29027
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 5 times.
1205 if(f==256)
29028 {
29029 5 holditem=getItemID(itemsbuf,itype_triforcepiece,1);
29030 5 }
29031
29032 1205 draw_screen(tmpscr);
29033 1205 advanceframe(true);
29034
29035
1/2
✓ Branch 0 taken 1205 times.
✗ Branch 1 not taken.
1205 if(rSbtn())
29036 {
29037 conveyclk=3;
29038 int32_t tmp_subscr_clk = frame;
29039 dosubscr(&QMisc);
29040 newscr_clk += frame - tmp_subscr_clk;
29041 }
29042
29043 1205 }
29044
29045 5 action=none; FFCore.setHeroAction(none);
29046 5 dir=up;
29047
29048
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
5 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && (tunes[MAXMIDIS-1].data))
29049 1 jukebox(MAXMIDIS-1);
29050 else
29051 4 playLevelMusic();
29052
29053 5 currcset=DMaps[currdmap].color;
29054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (get_bit(quest_rules, qr_GANONINTRO) )
29055 {
29056 5 dointro();
29057 //Yes, I checked. This is literally in 2.10 (minus this if statement of course).
29058 //I have no clue why it's here; Literally the only difference between dointro in 2.10 and dointro in this version is an 'else' that sets introclk and intropos to 74.
29059 //I have no idea what was going through the original devs heads and I'm extremely worried I'm missing something, cause at first glance this looks like
29060 //a hack solution to an underlying bug, but no! There's just a fucking dointro() call in older versions and I don't know *why*. -Deedee
29061 5 }
29062 //dointro(); //This is likely what causes Ganon Rooms to repeat the DMap intro.
29063 //I suppose it is to allow the user to make Gaanon rooms have their own dialogue, if they are
29064 //on a different DMap.
29065 //~ Otherwise, why is it here?! -Z
29066
29067
29068 //if ( !(DMaps[currdmap].flags&dmfALWAYSMSG) ) { dointro(); } //This is likely what causes Ganon Rooms to repeat the DMap intro.
29069 //If we try it this way: The dmap flag /always display intro string/ is probably why James had this issue.
29070
29071 //The only fix that I can think of, off the top of me head, is either a QR or a Screen Flag to disable the intro text.
29072 //Users who use that dmap rule should put ganons room on its own DMap! -Z
29073 5 cont_sfx(WAV_ROAR);
29074 5 }
29075
29076 4 void HeroClass::win_game()
29077 {
29078
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 replay_step_comment("win_game");
29079 4 Playing=Paused=false;
29080 4 action=won; FFCore.setHeroAction(won);
29081 4 Quit=qWON;
29082 4 hclk=0;
29083 4 x = 136;
29084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 y = (isdungeon() && currscr<128) ? 75 : 73;
29085 4 z = fakez = fall = fakefall = spins = 0;
29086 4 dir=left;
29087 4 }
29088
29089 7345 void HeroClass::reset_swordcharge()
29090 {
29091 7345 charging=spins=tapping=0;
29092 7345 }
29093
29094 8175 void HeroClass::reset_hookshot()
29095 {
29096
10/12
✓ Branch 0 taken 7746 times.
✓ Branch 1 taken 429 times.
✓ Branch 2 taken 7742 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 7720 times.
✓ Branch 5 taken 22 times.
✓ Branch 6 taken 7717 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 7717 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 7717 times.
8175 if(action!=walking && action!=rafting && action!=landhold1 && action!=landhold2 && action!=sidewaterhold1 && action!=sidewaterhold2)
29097 {
29098 7717 action=none; FFCore.setHeroAction(none);
29099 7717 }
29100
29101 8175 hookshot_frozen=false;
29102 8175 hookshot_used=false;
29103 8175 pull_hero=false;
29104 8175 hs_fix=false;
29105 8175 switchhookclk = switchhookmaxtime = switchhookstyle = switchhookarg = 0;
29106 8175 switch_hooked = false;
29107
1/2
✓ Branch 0 taken 8175 times.
✗ Branch 1 not taken.
8175 if(switching_object)
29108 switching_object->switch_hooked = false;
29109 8175 switching_object = NULL;
29110 8175 hooked_combopos = -1;
29111 8175 switchhook_cost_item = -1;
29112 8175 hooked_layerbits = 0;
29113
2/2
✓ Branch 0 taken 57225 times.
✓ Branch 1 taken 8175 times.
65400 for(auto q = 0; q < 7; ++q)
29114 57225 hooked_undercombos[q] = -1;
29115 8175 Lwpns.del(Lwpns.idFirst(wHSHandle));
29116 8175 Lwpns.del(Lwpns.idFirst(wHookshot));
29117 8175 chainlinks.clear();
29118
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 8111 times.
8175 int32_t index=directItem>-1 ? directItem : current_item_id(hs_switcher ? itype_switchhook : itype_hookshot);
29119 8175 hs_switcher = false;
29120
29121
2/2
✓ Branch 0 taken 7131 times.
✓ Branch 1 taken 1044 times.
8175 if(index>=0)
29122 {
29123 1044 stop_sfx(itemsbuf[index].usesound);
29124 1044 }
29125
29126 8175 hs_xdist=0;
29127 8175 hs_ydist=0;
29128 8175 }
29129
29130
29131 2449757 bool HeroClass::can_deploy_ladder()
29132 {
29133
2/2
✓ Branch 0 taken 309377 times.
✓ Branch 1 taken 2140380 times.
3688874 bool ladderallowed = ((!get_bit(quest_rules,qr_LADDERANYWHERE) && tmpscr->flags&fLADDER) || isdungeon()
29134
4/4
✓ Branch 0 taken 901263 times.
✓ Branch 1 taken 1239117 times.
✓ Branch 2 taken 52642 times.
✓ Branch 3 taken 1186475 times.
2140380 || (get_bit(quest_rules,qr_LADDERANYWHERE) && !(tmpscr->flags&fLADDER)));
29135
8/10
✓ Branch 0 taken 732548 times.
✓ Branch 1 taken 1717209 times.
✓ Branch 2 taken 698310 times.
✓ Branch 3 taken 34238 times.
✓ Branch 4 taken 698249 times.
✓ Branch 5 taken 61 times.
✓ Branch 6 taken 698249 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 698249 times.
3148006 return (current_item_id(itype_ladder)>-1 && ladderallowed && !ilswim && z==0 && fakez==0 &&
29136
2/2
✓ Branch 0 taken 677569 times.
✓ Branch 1 taken 20680 times.
698249 (!isSideViewHero() || on_sideview_solid_oldpos(x,y,old_x,old_y)));
29137 }
29138
29139 3068288 void HeroClass::reset_ladder()
29140 {
29141 3068288 ladderx=laddery=0;
29142 3068288 }
29143
29144 bool is_conveyor(int32_t type);
29145 int32_t get_conveyor(int32_t x, int32_t y);
29146
29147 3394919 void HeroClass::check_conveyor()
29148 {
29149 3394919 ++newconveyorclk;
29150
1/2
✓ Branch 0 taken 3394919 times.
✗ Branch 1 not taken.
3394919 if (newconveyorclk < 0) newconveyorclk = 0;
29151
29152
14/18
✓ Branch 0 taken 3394919 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3394919 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3394215 times.
✓ Branch 5 taken 704 times.
✓ Branch 6 taken 3394215 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3394215 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3392103 times.
✓ Branch 11 taken 2112 times.
✓ Branch 12 taken 3391958 times.
✓ Branch 13 taken 145 times.
✓ Branch 14 taken 3388689 times.
✓ Branch 15 taken 3269 times.
✓ Branch 16 taken 3388689 times.
✓ Branch 17 taken 3269 times.
3394919 if(action==casting||action==sideswimcasting||action==drowning || action==sidedrowning||action==lavadrowning||inlikelike||pull_hero||((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)))
29153 {
29154 6230 is_conveyor_stunned = 0;
29155 6230 return;
29156 }
29157
29158 3388689 WalkflagInfo info;
29159 int32_t xoff,yoff;
29160 3388689 zfix deltax(0), deltay(0);
29161 3388689 int32_t cmbid = get_conveyor(x+7,y+(bigHitbox?8:12));
29162
2/2
✓ Branch 0 taken 2261174 times.
✓ Branch 1 taken 1127515 times.
3388689 if(cmbid < 0)
29163 {
29164
2/2
✓ Branch 0 taken 2260491 times.
✓ Branch 1 taken 683 times.
2261174 if (conveyclk <= 0) is_on_conveyor=false;
29165 2261174 return;
29166 }
29167 1127515 newcombo const* cmb = &combobuf[cmbid];
29168 1127515 auto pos = COMBOPOS(x+7,y+(bigHitbox?8:12));
29169 1127515 bool custom_spd = (cmb->usrflags&cflag2);
29170
3/4
✓ Branch 0 taken 1126687 times.
✓ Branch 1 taken 828 times.
✓ Branch 2 taken 1126687 times.
✗ Branch 3 not taken.
1127515 if(custom_spd || conveyclk<=0) //!DIMITODO: let player be on multiple conveyors at once
29171 {
29172 1127515 int32_t ctype=cmb->type;
29173
3/4
✓ Branch 0 taken 828 times.
✓ Branch 1 taken 1126687 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 828 times.
1127515 auto rate = custom_spd ? zc_max(cmb->attribytes[0], 1) : 3;
29174
3/4
✓ Branch 0 taken 828 times.
✓ Branch 1 taken 1126687 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 828 times.
1127515 if(custom_spd && (newconveyorclk % rate)) return;
29175
3/4
✓ Branch 0 taken 675 times.
✓ Branch 1 taken 1126840 times.
✓ Branch 2 taken 675 times.
✗ Branch 3 not taken.
1127515 if((cmb->usrflags&cflag5) && HasHeavyBoots())
29176 return;
29177 1127515 is_on_conveyor=false;
29178 1127515 is_conveyor_stunned=0;
29179
29180 1127515 deltax=combo_class_buf[ctype].conveyor_x_speed;
29181 1127515 deltay=combo_class_buf[ctype].conveyor_y_speed;
29182
29183
3/4
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 1126759 times.
✓ Branch 2 taken 756 times.
✗ Branch 3 not taken.
1127515 if (is_conveyor(ctype) && custom_spd)
29184 {
29185 deltax = zslongToFix(cmb->attributes[0]);
29186 deltay = zslongToFix(cmb->attributes[1]);
29187 }
29188
29189
8/8
✓ Branch 0 taken 1127095 times.
✓ Branch 1 taken 420 times.
✓ Branch 2 taken 1126759 times.
✓ Branch 3 taken 336 times.
✓ Branch 4 taken 11082 times.
✓ Branch 5 taken 1115677 times.
✓ Branch 6 taken 5304 times.
✓ Branch 7 taken 5778 times.
1127515 if((deltax==0&&deltay==0)&&(isSideViewHero() && on_sideview_solid_oldpos(x,y,old_x,old_y)))
29190 {
29191 5778 cmbid = MAPCOMBO(x+8,y+16);
29192 5778 cmb = &combobuf[cmbid];
29193 5778 custom_spd = cmb->usrflags&cflag2;
29194 5778 ctype=(cmb->type);
29195 5778 deltax=combo_class_buf[ctype].conveyor_x_speed;
29196 5778 deltay=combo_class_buf[ctype].conveyor_y_speed;
29197
2/4
✓ Branch 0 taken 5778 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5778 times.
✗ Branch 3 not taken.
5778 if ((deltax != 0 || deltay != 0) && custom_spd)
29198 {
29199 deltax = zslongToFix(cmb->attributes[0]);
29200 deltay = zslongToFix(cmb->attributes[1]);
29201 }
29202 5778 }
29203
29204
4/4
✓ Branch 0 taken 1127095 times.
✓ Branch 1 taken 420 times.
✓ Branch 2 taken 336 times.
✓ Branch 3 taken 1126759 times.
1127515 if(deltax!=0||deltay!=0)
29205 {
29206 756 is_on_conveyor=true;
29207 756 }
29208 1126759 else return;
29209
29210 756 bool movedx = false, movedy = false;
29211
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(cmb->usrflags&cflag4) //Smart corners
29212 {
29213 if(deltay<0)
29214 {
29215 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
29216 execute(info);
29217
29218 if(!info.isUnwalkable())
29219 {
29220 movedy = true;
29221 zfix step(0);
29222
29223 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29224 {
29225 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
29226 {
29227 yoff=int32_t(y-step)&7;
29228
29229 if(!yoff) break;
29230
29231 step++;
29232 }
29233 }
29234 else
29235 {
29236 step=abs(deltay);
29237 }
29238
29239 y=y-step;
29240 hs_starty-=step.getInt();
29241
29242 for(int32_t j=0; j<chainlinks.Count(); j++)
29243 {
29244 chainlinks.spr(j)->y-=step;
29245 }
29246
29247 if(Lwpns.idFirst(wHookshot)>-1)
29248 {
29249 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
29250 }
29251
29252 if(Lwpns.idFirst(wHSHandle)>-1)
29253 {
29254 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
29255 }
29256 }
29257 }
29258 else if(deltay>0)
29259 {
29260 info = walkflag(x,y+15+2,2,down);
29261 execute(info);
29262
29263 if(!info.isUnwalkable())
29264 {
29265 movedy = true;
29266 zfix step(0);
29267
29268 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29269 {
29270 while(step<abs(deltay))
29271 {
29272 yoff=int32_t(y+step)&7;
29273
29274 if(!yoff) break;
29275
29276 step++;
29277 }
29278 }
29279 else
29280 {
29281 step=abs(deltay);
29282 }
29283
29284 y=y+step;
29285 hs_starty+=step.getInt();
29286
29287 for(int32_t j=0; j<chainlinks.Count(); j++)
29288 {
29289 chainlinks.spr(j)->y+=step;
29290 }
29291
29292 if(Lwpns.idFirst(wHookshot)>-1)
29293 {
29294 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
29295 }
29296
29297 if(Lwpns.idFirst(wHSHandle)>-1)
29298 {
29299 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
29300 }
29301 }
29302 }
29303
29304 if(deltax<0)
29305 {
29306 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
29307 execute(info);
29308
29309 if(!info.isUnwalkable())
29310 {
29311 movedx = true;
29312 zfix step(0);
29313
29314 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29315 {
29316 while(step<abs(deltax))
29317 {
29318 xoff=int32_t(x-step)&7;
29319
29320 if(!xoff) break;
29321
29322 step++;
29323 }
29324 }
29325 else
29326 {
29327 step=abs(deltax);
29328 }
29329
29330 x=x-step;
29331 hs_startx-=step.getInt();
29332
29333 for(int32_t j=0; j<chainlinks.Count(); j++)
29334 {
29335 chainlinks.spr(j)->x-=step;
29336 }
29337
29338 if(Lwpns.idFirst(wHookshot)>-1)
29339 {
29340 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
29341 }
29342
29343 if(Lwpns.idFirst(wHSHandle)>-1)
29344 {
29345 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
29346 }
29347 }
29348 }
29349 else if(deltax>0)
29350 {
29351 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
29352 execute(info);
29353
29354 if(!info.isUnwalkable())
29355 {
29356 movedx = true;
29357 zfix step(0);
29358
29359 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29360 {
29361 while(step<abs(deltax))
29362 {
29363 xoff=int32_t(x+step)&7;
29364
29365 if(!xoff) break;
29366
29367 step++;
29368 }
29369 }
29370 else
29371 {
29372 step=abs(deltax);
29373 }
29374
29375 x=x+step;
29376 hs_startx+=step.getInt();
29377
29378 for(int32_t j=0; j<chainlinks.Count(); j++)
29379 {
29380 chainlinks.spr(j)->x+=step;
29381 }
29382
29383 if(Lwpns.idFirst(wHookshot)>-1)
29384 {
29385 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
29386 }
29387
29388 if(Lwpns.idFirst(wHSHandle)>-1)
29389 {
29390 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
29391 }
29392 }
29393 }
29394 if(deltax && !movedx)
29395 y = COMBOY(pos);
29396 if(deltay && !movedy)
29397 x = COMBOX(pos);
29398 }
29399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 756 times.
756 if(!movedy)
29400 {
29401
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 681 times.
756 if(deltay<0)
29402 {
29403 75 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
29404 75 execute(info);
29405
29406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(!info.isUnwalkable())
29407 {
29408 75 movedy = true;
29409 75 zfix step(0);
29410
29411
9/10
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 27 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
75 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29412 {
29413
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
29414 {
29415 4 yoff=int32_t(y-step)&7;
29416
29417
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!yoff) break;
29418
29419 4 step++;
29420 }
29421 2 }
29422 else
29423 {
29424 73 step=abs(deltay);
29425 }
29426
29427 75 y=y-step;
29428 75 hs_starty-=step.getInt();
29429
29430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 for(int32_t j=0; j<chainlinks.Count(); j++)
29431 {
29432 chainlinks.spr(j)->y-=step;
29433 }
29434
29435
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(Lwpns.idFirst(wHookshot)>-1)
29436 {
29437 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
29438 }
29439
29440
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(Lwpns.idFirst(wHSHandle)>-1)
29441 {
29442 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
29443 }
29444 75 }
29445 else checkdamagecombos(x,y+8-(bigHitbox ? 8 : 0)-2);
29446 75 }
29447
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 261 times.
681 else if(deltay>0)
29448 {
29449 261 info = walkflag(x,y+15+2,2,down);
29450 261 execute(info);
29451
29452
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 156 times.
261 if(!info.isUnwalkable())
29453 {
29454 156 movedy = true;
29455 156 zfix step(0);
29456
29457
8/10
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 118 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 22 times.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 16 times.
156 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29458 {
29459
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 28 times.
40 while(step<abs(deltay))
29460 {
29461 28 yoff=int32_t(y+step)&7;
29462
29463
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 4 times.
28 if(!yoff) break;
29464
29465 24 step++;
29466 }
29467 16 }
29468 else
29469 {
29470 140 step=abs(deltay);
29471 }
29472
29473 156 y=y+step;
29474 156 hs_starty+=step.getInt();
29475
29476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
156 for(int32_t j=0; j<chainlinks.Count(); j++)
29477 {
29478 chainlinks.spr(j)->y+=step;
29479 }
29480
29481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
156 if(Lwpns.idFirst(wHookshot)>-1)
29482 {
29483 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
29484 }
29485
29486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
156 if(Lwpns.idFirst(wHSHandle)>-1)
29487 {
29488 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
29489 }
29490 156 }
29491 105 else checkdamagecombos(x,y+15);
29492 261 }
29493 756 }
29494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 756 times.
756 if(!movedx)
29495 {
29496
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 502 times.
756 if(deltax<0)
29497 {
29498 254 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
29499 254 execute(info);
29500
29501
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 204 times.
254 if(!info.isUnwalkable())
29502 {
29503 204 movedx = true;
29504 204 zfix step(0);
29505
29506
8/10
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 180 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 19 times.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
204 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29507 {
29508
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 10 times.
15 while(step<abs(deltax))
29509 {
29510 10 xoff=int32_t(x-step)&7;
29511
29512
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(!xoff) break;
29513
29514 10 step++;
29515 }
29516 5 }
29517 else
29518 {
29519 199 step=abs(deltax);
29520 }
29521
29522 204 x=x-step;
29523 204 hs_startx-=step.getInt();
29524
29525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 for(int32_t j=0; j<chainlinks.Count(); j++)
29526 {
29527 chainlinks.spr(j)->x-=step;
29528 }
29529
29530
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(Lwpns.idFirst(wHookshot)>-1)
29531 {
29532 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
29533 }
29534
29535
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(Lwpns.idFirst(wHSHandle)>-1)
29536 {
29537 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
29538 }
29539 204 }
29540 50 else checkdamagecombos(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0));
29541 254 }
29542
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 166 times.
502 else if(deltax>0)
29543 {
29544 166 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
29545 166 execute(info);
29546
29547
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 164 times.
166 if(!info.isUnwalkable())
29548 {
29549 164 movedx = true;
29550 164 zfix step(0);
29551
29552
8/10
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 28 times.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 14 times.
164 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29553 {
29554
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 27 times.
39 while(step<abs(deltax))
29555 {
29556 27 xoff=int32_t(x+step)&7;
29557
29558
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 2 times.
27 if(!xoff) break;
29559
29560 25 step++;
29561 }
29562 14 }
29563 else
29564 {
29565 150 step=abs(deltax);
29566 }
29567
29568 164 x=x+step;
29569 164 hs_startx+=step.getInt();
29570
29571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 164 times.
164 for(int32_t j=0; j<chainlinks.Count(); j++)
29572 {
29573 chainlinks.spr(j)->x+=step;
29574 }
29575
29576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 164 times.
164 if(Lwpns.idFirst(wHookshot)>-1)
29577 {
29578 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
29579 }
29580
29581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 164 times.
164 if(Lwpns.idFirst(wHSHandle)>-1)
29582 {
29583 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
29584 }
29585 164 }
29586 2 else checkdamagecombos(x+15+2,y+8-(bigHitbox ? 8 : 0));
29587 166 }
29588 756 }
29589
4/4
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 368 times.
✓ Branch 2 taken 231 times.
✓ Branch 3 taken 157 times.
756 if(movedx || movedy)
29590 {
29591
1/2
✓ Branch 0 taken 599 times.
✗ Branch 1 not taken.
599 if(cmb->usrflags&cflag1)
29592 is_conveyor_stunned = rate;
29593
1/2
✓ Branch 0 taken 599 times.
✗ Branch 1 not taken.
599 if(cmb->usrflags&cflag3)
29594 {
29595 if(abs(deltax) > abs(deltay))
29596 dir = (deltax > 0) ? right : left;
29597 else dir = (deltay > 0) ? down : up;
29598 }
29599 599 }
29600 756 }
29601 3394919 }
29602
29603 void HeroClass::setNayrusLoveShieldClk(int32_t newclk)
29604 {
29605 NayrusLoveShieldClk=newclk;
29606
29607 if(decorations.idCount(dNAYRUSLOVESHIELD)==0)
29608 {
29609 decoration *dec;
29610 decorations.add(new dNayrusLoveShield(HeroX(), HeroY(), dNAYRUSLOVESHIELD, 0));
29611 decorations.spr(decorations.Count()-1)->misc=0;
29612 decorations.add(new dNayrusLoveShield(HeroX(), HeroY(), dNAYRUSLOVESHIELD, 0));
29613 dec=(decoration *)decorations.spr(decorations.Count()-1);
29614 decorations.spr(decorations.Count()-1)->misc=1;
29615 }
29616 }
29617
29618 6417 int32_t HeroClass::getNayrusLoveShieldClk()
29619 {
29620 6417 return NayrusLoveShieldClk;
29621 }
29622
29623 int32_t HeroClass::getHoverClk()
29624 {
29625 return hoverclk;
29626 }
29627
29628 2618343 int32_t HeroClass::getHoldClk()
29629 {
29630 2618343 return holdclk;
29631 }
29632
29633 3734482 int32_t HeroClass::getLastLensID(){
29634 3734482 return last_lens_id;
29635 }
29636
29637 197 void HeroClass::setLastLensID(int32_t p_item){
29638 197 last_lens_id = p_item;
29639 197 }
29640
29641 28345016 bool HeroClass::getOnSideviewLadder()
29642 {
29643 28345016 return on_sideview_ladder;
29644 }
29645
29646 71 void HeroClass::setOnSideviewLadder(bool val)
29647 {
29648
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 5 times.
71 if(val)
29649 {
29650 5 fall = fakefall = hoverclk = jumping = 0;
29651 5 hoverflags = 0;
29652 5 inair = false;
29653 5 }
29654 71 on_sideview_ladder = val;
29655 71 }
29656
29657 1048620 bool HeroClass::canSideviewLadder(bool down)
29658 {
29659
2/2
✓ Branch 0 taken 1045066 times.
✓ Branch 1 taken 3554 times.
1048620 if(!isSideViewHero()) return false;
29660
2/2
✓ Branch 0 taken 3442 times.
✓ Branch 1 taken 112 times.
3554 if(jumping < 0) return false;
29661
3/4
✓ Branch 0 taken 1400 times.
✓ Branch 1 taken 2042 times.
✓ Branch 2 taken 1400 times.
✗ Branch 3 not taken.
3442 if(down && get_bit(quest_rules, qr_DOWN_DOESNT_GRAB_LADDERS))
29662 {
29663 bool onSolid = on_sideview_solid_oldpos(x,y,old_x,old_y,true);
29664 return ((isSVLadder(x+4,y+16) && (!isSVLadder(x+4,y)||onSolid)) || (isSVLadder(x+12,y+16) && (!isSVLadder(x+12,y)||onSolid)));
29665 }
29666 //Are you presently able to climb a sideview ladder?
29667 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
29668 //y+0 checks your top-half for large hitbox; y+8 for small
29669 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
29670 //y+16 check is for going down onto a ladder you are standing on.
29671
2/2
✓ Branch 0 taken 3164 times.
✓ Branch 1 taken 278 times.
6535 return (isSVLadder(x+4,y+(bigHitbox?0:8)) || isSVLadder(x+12,y+(bigHitbox?0:8)))
29672
4/4
✓ Branch 0 taken 3093 times.
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 3009 times.
✓ Branch 3 taken 84 times.
3164 || isSVLadder(x+4,y+15) || isSVLadder(x+12,y+15)
29673
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3009 times.
✓ Branch 2 taken 1609 times.
✓ Branch 3 taken 1400 times.
✓ Branch 4 taken 1400 times.
✗ Branch 5 not taken.
4409 || (down && (isSVLadder(x+4,y+16) || isSVLadder(x+12,y+16)));
29674 1048620 }
29675
29676 bool HeroClass::canSideviewLadderRemote(int32_t wx, int32_t wy, bool down)
29677 {
29678 if(!isSideViewHero()) return false;
29679 if(jumping < 0) return false;
29680 if(down && get_bit(quest_rules, qr_DOWN_DOESNT_GRAB_LADDERS))
29681 {
29682 bool onSolid = on_sideview_solid_oldpos(x,y,old_x,old_y,true);
29683 return ((isSVLadder(wx+4,wy+16) && (!isSVLadder(wx+4,wy)||onSolid)) || (isSVLadder(wx+12,wy+16) && (!isSVLadder(wx+12,wy)||onSolid)));
29684 }
29685 //Are you presently able to climb a sideview ladder?
29686 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
29687 //y+0 checks your top-half for large hitbox; y+8 for small
29688 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
29689 //y+16 check is for going down onto a ladder you are standing on.
29690 return (isSVLadder(wx+4,wy+(bigHitbox?0:8)) || isSVLadder(wx+12,wy+(bigHitbox?0:8)))
29691 || isSVLadder(wx+4,wy+15) || isSVLadder(wx+12,wy+15)
29692 || (down && (isSVLadder(wx+4,wy+16) || isSVLadder(wx+12,wy+16)));
29693 }
29694
29695 2151839 void HeroClass::execute(HeroClass::WalkflagInfo info)
29696 {
29697 2151839 int32_t flags = info.getFlags();
29698
29699
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 2151587 times.
2151839 if(flags & WalkflagInfo::CLEARILSWIM)
29700 252 ilswim =false;
29701
2/2
✓ Branch 0 taken 2151384 times.
✓ Branch 1 taken 203 times.
2151587 else if(flags & WalkflagInfo::SETILSWIM)
29702 203 ilswim = true;
29703
29704
1/2
✓ Branch 0 taken 2151839 times.
✗ Branch 1 not taken.
2151839 if(flags & WalkflagInfo::CLEARCHARGEATTACK)
29705 {
29706 charging = 0;
29707 attackclk = 0;
29708 }
29709
29710
1/2
✓ Branch 0 taken 2151839 times.
✗ Branch 1 not taken.
2151839 if(flags & WalkflagInfo::SETDIR)
29711 {
29712 dir = info.getDir();
29713 }
29714
29715
2/2
✓ Branch 0 taken 2151604 times.
✓ Branch 1 taken 235 times.
2151839 if(flags & WalkflagInfo::SETHOPCLK)
29716 {
29717 235 hopclk = info.getHopClk();
29718 235 }
29719
29720
2/2
✓ Branch 0 taken 2151721 times.
✓ Branch 1 taken 118 times.
2151839 if(flags & WalkflagInfo::SETHOPDIR)
29721 {
29722 118 hopdir = info.getHopDir();
29723 118 }
29724
29725 2151839 }
29726
29727 4437955 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator ||(HeroClass::WalkflagInfo other)
29728 {
29729 4437955 HeroClass::WalkflagInfo ret;
29730 4437955 ret.newhopclk = newhopclk;
29731 4437955 ret.newdir = newdir;
29732
2/2
✓ Branch 0 taken 3623779 times.
✓ Branch 1 taken 814176 times.
4437955 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
29733
29734 4437955 int32_t flags1 = (flags & ~UNWALKABLE) & (other.flags & ~UNWALKABLE);
29735 4437955 int32_t flags2 = (flags & UNWALKABLE) | (other.flags & UNWALKABLE);
29736 4437955 ret.flags = flags1 | flags2;
29737 4437955 return ret;
29738 }
29739
29740 6550 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator &&(HeroClass::WalkflagInfo other)
29741 {
29742 6550 HeroClass::WalkflagInfo ret;
29743 6550 ret.newhopclk = newhopclk;
29744 6550 ret.newdir = newdir;
29745
1/2
✓ Branch 0 taken 6550 times.
✗ Branch 1 not taken.
6550 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
29746
29747 6550 ret.flags = flags & other.flags;
29748 6550 return ret;
29749 }
29750
29751 6550 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator !()
29752 {
29753 6550 HeroClass::WalkflagInfo ret;
29754 6550 ret.newhopclk = newhopclk;
29755 6550 ret.newdir = newdir;
29756 6550 ret.newhopdir = newhopdir;
29757
29758 6550 ret.flags = flags ^ UNWALKABLE;
29759 6550 return ret;
29760 }
29761
29762 void HeroClass::explode(int32_t type)
29763 {
29764 static int32_t tempx, tempy;
29765 static byte herotilebuf[256];
29766 int32_t ltile=0;
29767 int32_t lflip=0;
29768 bool shieldModify=true;
29769 unpack_tile(newtilebuf, tile, flip, true);
29770 memcpy(herotilebuf, unpackbuf, 256);
29771 tempx=Hero.getX();
29772 tempy=Hero.getY();
29773 for(int32_t i=0; i<16; ++i)
29774 {
29775 for(int32_t j=0; j<16; ++j)
29776 {
29777 if(herotilebuf[i*16+j])
29778 {
29779 if(type==0) // Twilight
29780 {
29781 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 0, 0, (zc_oldrand()%8)+i*4));
29782 int32_t k=particles.Count()-1;
29783 particle *p = (particles.at(k));
29784 p->step=3;
29785 }
29786 else if(type ==1) // Sands of Hours
29787 {
29788 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 1, 2, (zc_oldrand()%16)+i*2));
29789 int32_t k=particles.Count()-1;
29790 particle *p = (particles.at(k));
29791 p->step=4;
29792
29793 if(zc_oldrand()%10 < 2)
29794 {
29795 p->color=1;
29796 p->cset=0;
29797 }
29798 }
29799 else
29800 {
29801 particles.add(new pFaroresWindDust(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 6, herotilebuf[i*16+j], zc_oldrand()%96));
29802
29803 int32_t k=particles.Count()-1;
29804 particle *p = (particles.at(k));
29805 p->angular=true;
29806 p->angle=zc_oldrand();
29807 p->step=(((double)j)/8);
29808 p->yofs=Hero.getYOfs();
29809 }
29810 }
29811 }
29812 }
29813 }
29814
29815 463 void HeroClass::SetSwim()
29816 {
29817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 463 times.
463 if (CanSideSwim())
29818 {
29819 if (action != sideswimattacking && action != attacking) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
29820 else {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
29821 if (get_bit(quest_rules,qr_SIDESWIMDIR) && spins <= 0 && dir != left && dir != right) dir = sideswimdir;
29822 }
29823 463 else {action=swimming; FFCore.setHeroAction(swimming);}
29824 463 }
29825
29826 39942 void HeroClass::SetAttack()
29827 {
29828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39942 times.
39942 if (IsSideSwim()) {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
29829 39942 else {action=attacking; FFCore.setHeroAction(attacking);}
29830 39942 }
29831
29832 28197947 bool HeroClass::IsSideSwim()
29833 {
29834
6/12
✓ Branch 0 taken 28197947 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28197947 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 28197947 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 28197947 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 28197947 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 28197947 times.
28197947 return (action==sideswimming || action==sideswimhit || action == sideswimattacking || action == sidewaterhold1 || action == sidewaterhold2 || action == sideswimcasting || action == sideswimfreeze);
29835 }
29836
29837 680615 bool HeroClass::CanSideSwim()
29838 {
29839
1/2
✓ Branch 0 taken 680615 times.
✗ Branch 1 not taken.
680615 return (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM));
29840 }
29841
29842 2607818 int32_t HeroClass::getTileModifier()
29843 {
29844 2607818 return item_tile_mod() + bunny_tile_mod();
29845 }
29846 void HeroClass::setImmortal(int32_t nimmortal)
29847 {
29848 immortal = nimmortal;
29849 }
29850 void HeroClass::kill(bool bypassFairy)
29851 {
29852 dying_flags = DYING_FORCED | (bypassFairy ? DYING_NOREV : 0);
29853 }
29854 6807194 bool HeroClass::sideview_mode() const
29855 {
29856
3/4
✓ Branch 0 taken 70433 times.
✓ Branch 1 taken 6736761 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 70433 times.
6807194 return isSideViewHero() && (moveflags & FLAG_OBEYS_GRAV) && !toogam;
29857 }
29858 13071 bool HeroClass::is_unpushable() const
29859 {
29860 13071 return toogam;
29861 }
29862 /*** end of hero.cpp ***/
29863
29864
29865
29866
29867